Reputation: 55
I would need to start a batch script at boot before the user to log in with his credentials.
How could I do?
Thank you all
Upvotes: 1
Views: 2416
Reputation: 8803
If you can edit the system's registry, you can run regedit.exe and add browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices
. Add a new string value, with an arbitrary name, and the full batch path as value.
I think this will be executed every time Windows is booted. Not sure about if it will be run after awakening from an hibernation period.
Not to be mistaked with HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
, which happens every time any user logs in (thanks to Harry Johnston), or HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
, which happens every time a certain user logs in.
Upvotes: 0
Reputation: 18837
You can take a look at this How to launch a program before the shell (Explorer) starts.
If you want to start an application before the shell starts, you can add a value to the Userinit
value in the registry. In this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
There is a value named Userinit
. Change it so your program is run before userinit.exe. For example, to start notepad before the shell/everything else is initialized:
C:\WINDOWS\system32\notepad.exe,C:\Windows\system32\userinit.exe
Use commas to separate the programs that should be started.
So the same thing for your batch file just add the absolute path instead of the notepad example
Upvotes: 2
Reputation: 143
There's 2 keys that you can edit from the local registry
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
If HKLM (HKEY_LOCAL_MACHINE) is modified it will affect the entire machine, so the batch file will run no matter who logs in, while HKCU (HKEY_CURRENT_USER) will only affect the currently logged in user when the registry is modified. You can also add, modify or verify the current existance of either of the above keys from your batch file, just open a command prompt and type REG /?
to view available commands.
Upvotes: 0