c# - My application will not automatically start with windows - what is wrong here? -


i using following code manage automatic startup of application. application has been set require admin privileges, , indeed, ask them.

registrykey rkapp = registry.currentuser.opensubkey("software\\microsoft\\windows\\currentversion\\run", true); if (checkrunonstartup.checked) {     rkapp.setvalue("myapp", application.executablepath.tostring()); } else {     rkapp.deletevalue("myapp", false); } 

this not work on system have tested on, except development machine. doing wrong here?

instead of writing reg keys create/delete shortcut app in windows startup folder. environment.specialfolder.startup return path. if dead set on reg key option here snippet of code per dotnetthoughts . seems main difference dropped .tostring().

private void registerinstartup(bool ischecked) {    registrykey registrykey = registry.currentuser.opensubkey         ("software\\microsoft\\windows\\currentversion\\run", true);    if (ischecked)    {        registrykey.setvalue("applicationname", application.executablepath);    }    else    {      registrykey.deletevalue("applicationname");    } } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -