I'm trying to make a bat file run at boot by adding it to the system registry; the bat is very easy, it's just:
mkdir new
Obviously when I normally run it, it works and a folder named "new" spawns in the bat file directory(Desktop), but when I try to add the file to both "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run" and
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", add a string like "C:\[…]\Desktop\test.bat", on boot I see for a moment a cmd windows pop up and then immediately close but no "new" folder. Does anyone know how to solve that?
Best Answer
A start-up key such as:
...where "run.bat" contains:
..will start in the following directory: "C:\windows\system32\".
The command line will be:
and it will be running as the user "bob".
Trying to create a directory in "C:\WINDOWS\system32\" will get you access denied.
If you like, you can put the command:
in the batch file "before" and "after" your command(s) so you can see it happen at logon. You can even run Process Monitor (https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx) after the first pause to see the outcome.