Answer the question
In order to leave comments, you need to log in
How to add a program to startup or task scheduler via .bat?
Good afternoon.
There is a very interesting problem, but I can not solve it.
The bottom line is:
1. There is a computer with 2 accounts (Admin and User).
2. Admin has admin rights.
2. The user does not have administrator rights. (Accordingly, if you run something on the Administrator's behalf, you need to enter the password from the Admin account)
3. There is one program that should be launched once when the User logs in.
Question: How to run the program when I log in?
- You will say add to task scheduler or startup.
Let's look at the task scheduler option . It's so easy to run without admin rights - it won't work, you need rights. OK. We make a .bat file and write:
md "%appdata%\Lbama"
copy Lbama.exe "%appdata%\Lbama"
copy start.VBS "%appdata%\Lbama"
SCHTASKS /Create /ru "SYSTEM" /v1 /SC ONSTART /TN Lbama/TR "\"%appdata%\Lbama\start.VBS""
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Lbama /t REG_SZ /d "appdata%\Lbama\Lbama.exe" /f
Answer the question
In order to leave comments, you need to log in
I will answer for myself and for the future like me.
Don't worry, everything can be done with one line of code
You just copy the program to the current user's startup folder and EVERYTHING works, no need to use the task scheduler or register.
Everything is ingeniously simple
About Winlogon - it can be seen such a joke was.
Actually the key in the registry is slightly different:
"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
The same key exists in the user's registry.
In HKLM, it starts when the computer starts with system rights, so you need to write the path in full, from HKCU with the rights of the user whose launch is registered.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question