0

I have a simple batch file which adds registry with reg add command.

reg add "HKLM\SOFTWARE\test\test" /f /v "MainDir" /t REG_SZ /d "test"

When I run the bach from a network drive everithing looks fine but no registry was added. When I copy the batch to to my desktop and run it it works perfectly.

I tried to use PUSHD but wont help, only thing what works is creating a shortcut and in the shortcut add %TEMP% to start in

Frodo
  • 1
  • 3
  • can you add a `pause` right after the `reg` command when running on network drive? Is the network drive mounted on a drive letter or do you access it wia UNC? is there some security policies that prevent the execution of files on your network drives? – Jean-François Fabre Aug 04 '16 at 11:04
  • Did you try to run it as [admin](http://stackoverflow.com/questions/38642927/simple-method-to-run-a-batch-as-administrator-using-javascript/38650025#38650025)? – sambul35 Aug 04 '16 at 12:48
  • I already use PAUSE command to see the output and REG yells "The operation completed successfully", therefore I say that everythink looks fine. Its mapped to a letter and I don't know abou any security policies that can be in use. It's really weird problem. – Frodo Aug 04 '16 at 14:52
  • Yes, I try run it as admin and moreover my acount have admin rights too. – Frodo Aug 04 '16 at 14:53
  • Add `reg query "HKLM\SOFTWARE\test\test" /v "MainDir"` before `pause` - what output now? – JosefZ Aug 04 '16 at 20:13
  • It returns `HKEY_LOCAL_MACHINE\SOFTWARE\test\test MainDir REG_SZ` test, when I look in to regedit still no changes. – Frodo Aug 05 '16 at 07:15

1 Answers1

0

I solved it. It was so unexpected. The problem was the Commander which I alway use in windows. Everytime I run the batch from commander it don't work, when I run it from explorer or something else it was ok. Soooo weird. The commander have admin right so I don't know why it dont work. Thanks all for help. :)

Frodo
  • 1
  • 3
  • The "commander" you are using is most likely a 32-bit application. Therefore double clicking on a batch file results in processing of the batch file with 32-bit `cmd.exe`. That results in adding the registry value with 32-bit `reg.exe` to `HKLM\SOFTWARE\Wow6432Node\test\test`. So adding the value was successful, but you looked with 64-bit `regedit` on wrong key. See [Registry Keys Affected by WOW64](https://msdn.microsoft.com/en-us/library/windows/desktop/aa384253.aspx) and [File System Redirector](https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187.aspx) for more details. – Mofi Aug 06 '16 at 09:56