Reputation: 685
My application need to start when windows start. so i writed a batch file for running the application.
This is the code for writing the batch file path entry to registry.
private void RegisterInStartup(bool isChecked)
{
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (isChecked)
{
registryKey.SetValue("ApplicationName", Application.StartupPath+"\\autorun.bat");
}
else
{
registryKey.DeleteValue("ApplicationName");
}
}
And this is my batch file code.
start File.exe
exit
When I restart my system the batch file is executing but the application File.exe is not executing.
Why this happening?
Upvotes: 0
Views: 503
Reputation: 4797
The batch file is not started from the directory where it exists. therefore File.exe will not be found. Replace batch with exe, or provide a full path to the exe as well.
Upvotes: 1
Reputation: 1388
Upvotes: 0