Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding an exe to start-up using batch

Need a batch file that can add and remove a .exe file from the start-up. Does any one know ho I could do it. When I say start-up I mean the exe executes when The user log's on. I am compileing the batch file with http://www.battoexeconverter.com/.

like image 917
09stephenb Avatar asked Feb 15 '23 10:02

09stephenb


2 Answers

You are trying to control the list of applications that are started when a user logs on. The keys that determine that are:

HKLM\Software\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\Run

Use the former to control applications started when any user logs on. Use the latter to control applications started when the current user logs on.

You want to do this in a batch file. So you need to use the standard tools for controlling registry keys. That means the reg tool.

So, add a value like this:

reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v MyApp /d myapp.exe

And remove the value like this:

reg delete HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v MyApp

If you want to use HKCU rather than HKLM then change the key appropriately. Obviously if you choose to use HKLM that will require elevation.

Do be prepared for the fact that many virus scanners will treat such activity as evidence that your program is malicious.

like image 82
David Heffernan Avatar answered Feb 17 '23 01:02

David Heffernan


If it's simpy an EXE, then copy it to the autostart-folder (or delete it from there):

C:\Users\thatsMe\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\

The name of this folder could change with different Windows-versons or localisations.

like image 24
Stephan Avatar answered Feb 17 '23 00:02

Stephan