Who can help? I need the program to throw itself into startup. I tried a lot that did not help for example:
There is one more news that my exe file does not start via cmd (command line); any other application launches mine no I write so start the path to the program I tried on d and c \ .exe
Through the code
Registry.CurrentUser.CreateSubKey (@ "Software \ Microsoft \ Windows \ CurrentVersion \ Run;
(does not work) it just doesn't start, it's as if it is there and it is on it doesn't start it I tried it through the other folder and through the USB flash drive evenly!
I tried to copy it to the startup folder manually, it launches fine, it starts up and everything works, but it can't throw its own shortcut saying that there are no admin rights, in the manifest it changed the launch line from the admin to the normal one and back when it is from the admin even when I manually threw it. I tried to move files through bad
The examples below do not work either.
RegistryKey rk = Registry.CurrentUser.OpenSubKey ("SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run", true); rk.SetValue ("FileName", "FileName.exe");
If you manually place the full path to the program in HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run
- does it work?
My code is:
public bool SetAutorunValue(bool autorun)
{
string ExePath = Application.ExecutablePath;
RegistryKey reg;
reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (autorun)
{
if (reg.GetValue(NameApp) == null)
{
reg.SetValue(NameApp, ExePath);
reg.Close();
return true;
}
else
return false;
}
else
{
if (reg.GetValue(NameApp) != null)
{
reg.DeleteValue(NameApp);
reg.Close();
return true;
}
else
return false;
}
}