I am trying to start a program I made in this directory:
C:\example\example.exe -someargument
when the computer starts up. I am attempting to use this registry key:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
with the key being:
Name: example
Type: REG_SZ
Data: "C:\example\example.exe -someargument"
But my program also needs files from the directory C:\example but can't find them since the current working directory is different. Is is possible to do something like this in the registry key value
"cd C:\example\; example.exe -someargument"
so that it will change the directory? Or is there a better solution?
Thanks!
The Run subkey—By far the most common registry location for autorun programs is the Run entry, which you'll find at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
The Registry contains information that Windows continually references during operation, such as profiles for each user, the applications installed on the computer and the types of documents that each can create, property sheet settings for folders and application icons, what hardware exists on the system, and the ports ...
You can also create a shortcut for the program in the folder and reference this shortcut in the registry:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
Name: example
Type: REG_SZ
Data: "C:\example\example.lnk
At the start of the application, do the following (this is C#, convert to C++):
using System.IO;
:
:
Environment.CurrentDirectory = Path.GetDirectoryName(Application.ExecutablePath);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With