i have one bat file with a command line for delete one reg key...
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\StillImage\Registered Applications" /f
if run this bat in XY this bat not work, ("error the key not exist"!);
if run same bat on win explorer, this work!!
why this???
problem with a .bat file
-
nas8e9
- Posts: 2232
- Joined: 21 Jun 2008 14:50
Re: problem with a .bat file
It seems related to WOW64: running a similar script in a 64-bit command prompt does work correctly. As for working around this, I'm not sure at the moment.swan_x wrote:i have one bat file with a command line for delete one reg key...
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\StillImage\Registered Applications" /f
if run this bat in XY this bat not work, ("error the key not exist"!);
if run same bat on win explorer, this work!!
why this???
-
admin
- Site Admin
- Posts: 66366
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: problem with a .bat file
You have a screenshot of the error message?swan_x wrote:i have one bat file with a command line for delete one reg key...
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\StillImage\Registered Applications" /f
if run this bat in XY this bat not work, ("error the key not exist"!);
if run same bat on win explorer, this work!!
why this???
FAQ | XY News RSS | XY X
-
swan_x
- Posts: 335
- Joined: 08 Oct 2009 12:27
Re: problem with a .bat file
no screenshot... 
if don't write /f (without confirmation) at the end:
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\StillImage\Registered Applications"
i have 2 choices Yes or Not
for every choice, the window closes immediately...but i see the error message:
<error: can not find the registry key or value specified>
this does not happen if i use win explorer...
at the end of my bat i have the message:
<operation completed>
and the key is deleted successfully!!
if don't write /f (without confirmation) at the end:
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\StillImage\Registered Applications"
i have 2 choices Yes or Not
for every choice, the window closes immediately...but i see the error message:
<error: can not find the registry key or value specified>
this does not happen if i use win explorer...
at the end of my bat i have the message:
<operation completed>
and the key is deleted successfully!!
-
swan_x
- Posts: 335
- Joined: 08 Oct 2009 12:27
Re: problem with a .bat file
yes i know! this is the problem!nas8e9 wrote:It seems related to WOW64: running a similar script in a 64-bit command prompt does work correctly. As for working around this, I'm not sure at the moment.swan_x wrote:i have one bat file with a command line for delete one reg key...
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\StillImage\Registered Applications" /f
if run this bat in XY this bat not work, ("error the key not exist"!);
if run same bat on win explorer, this work!!
why this???
-
swan_x
- Posts: 335
- Joined: 08 Oct 2009 12:27
Re: problem with a .bat file
try this:
run-regedit
in HKEY_LOCAL_MACHINE\SOFTWARE
creates new key 555
now copy this in new txt document, and save to xxx.bat:
REG DELETE HKLM\Software\555
ok, run xxx.bat from XY ---- you have window confirmation Y/N ---- hold Y ---- error (impossible find this key!!)
go to regedit, the key was not deleted !!
now open win explorer, run xxx.bat ----- you have window confirmation Y/N ---- hold Y ---- OK!!
go to regedit, key deleted !!
same result if "run as administartor" xxx.bat file from XY .... the result does not change!
run-regedit
in HKEY_LOCAL_MACHINE\SOFTWARE
creates new key 555
now copy this in new txt document, and save to xxx.bat:
REG DELETE HKLM\Software\555
ok, run xxx.bat from XY ---- you have window confirmation Y/N ---- hold Y ---- error (impossible find this key!!)
go to regedit, the key was not deleted !!
now open win explorer, run xxx.bat ----- you have window confirmation Y/N ---- hold Y ---- OK!!
go to regedit, key deleted !!
same result if "run as administartor" xxx.bat file from XY .... the result does not change!
-
nas8e9
- Posts: 2232
- Joined: 21 Jun 2008 14:50
Re: problem with a .bat file
I'm not sure my first post in this thread was clear, so:swan_x wrote:try this:
run-regedit
in HKEY_LOCAL_MACHINE\SOFTWARE
creates new key 555
now copy this in new txt document, and save to xxx.bat:
REG DELETE HKLM\Software\555
ok, run xxx.bat from XY ---- you have window confirmation Y/N ---- hold Y ---- error (impossible find this key!!)
go to regedit, the key was not deleted !!
now open win explorer, run xxx.bat ----- you have window confirmation Y/N ---- hold Y ---- OK!!
go to regedit, key deleted !!
same result if "run as administartor" xxx.bat file from XY .... the result does not change!
64-bit versions of Windows basically lie to 32-bit apps in order to preserve compatibility; this functionality is referred to as WOW64. Part of this system is registry virtualisation, where 32-bit apps's registry reads and writes are redirected to different parts of the registry.
The second piece of the puzzle is that when 32-bit apps call the command prompt (by executing a .bat file in your case), they get a 32-bit command prompt rather than the 64-bit one you get when starting one through Windows Explorer. As a result, .bat- or .cmd-files behave differently when run from a 32-bit app instead of (64-bit) Windows Explorer. That's what causes your registry access from a .bat-file to fail.
As for working around this problem, I don't know at the moment.
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: problem with a .bat file
On 64-bit OS, 32-bit apps have different locations then 64-bit apps
64-bit see and use: HKLM\SOFTWARE\
32-bit see and use: HKLM\SOFTWARE\Wow6432Node\ as there "HKLM\SOFTWARE\"
Take an look if you have an 32-bit version of REG.exe in your %systemroot%\syswow64\ folder.
Perhaps this will work then:
64-bit see and use: HKLM\SOFTWARE\
32-bit see and use: HKLM\SOFTWARE\Wow6432Node\ as there "HKLM\SOFTWARE\"
Take an look if you have an 32-bit version of REG.exe in your %systemroot%\syswow64\ folder.
Perhaps this will work then:
Code: Select all
IF %PROCESSOR_ARCHITEW6432%LEER==LEER (
REM 32
REG DELETE HKLM\Software\555
)else(
REM 64
%systemroot%\syswow64\REG DELETE HKLM\Software\555
)-
nas8e9
- Posts: 2232
- Joined: 21 Jun 2008 14:50
Re: problem with a .bat file
Thank you for the pointers! I had to make some changes (SysWOW64 vs. Sysnative) and ended up with this:Stefan wrote:On 64-bit OS, 32-bit apps have different locations then 64-bit apps
64-bit see and use: HKLM\SOFTWARE\
32-bit see and use: HKLM\SOFTWARE\Wow6432Node\ as there "HKLM\SOFTWARE\"
Take an look if you have an 32-bit version of REG.exe in your %systemroot%\syswow64\ folder.
Perhaps this will work then:Code: Select all
IF %PROCESSOR_ARCHITEW6432%LEER==LEER ( REM 32 REG DELETE HKLM\Software\555 )else( REM 64 %systemroot%\syswow64\REG DELETE HKLM\Software\555 )
Code: Select all
@ECHO OFF
IF DEFINED PROCESSOR_ARCHITEW6432 (
REM 32
ECHO "Called from a 32-bit process."
%systemroot%\sysnative\REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\StillImage\Registered Applications" /f
) ELSE (
REM 64
ECHO "Called from a 64-bit process."
REG DELETE "HKLM\Software\Microsoft\Windows\CurrentVersion\StillImage\Registered Applications" /f
)-
swan_x
- Posts: 335
- Joined: 08 Oct 2009 12:27
Re: problem with a .bat file
yeahhhh!!!
tnxs nas8e9
now work!!
%systemroot%\sysnative\REG DELETE HKLM\Software\555
............SOLVED !!!
tnxs nas8e9
now work!!
%systemroot%\sysnative\REG DELETE HKLM\Software\555
............SOLVED !!!
XYplorer Beta Club