c# - Running applications in Run and RunOnce Registry programmatically -


i have developed custom shell written in wpf/c# replaces explorer.exe shell on windows 8.1 system. runs fine, except run applications in run/runonce registry locations. main issue there seems no standard way of putting entries in registry - have double-quotes around entries, don't; run through rundll32 , have entry point defined followed comma-separated arguments; have space separated arguments; have few executables in 1 entry.
there service or executable can call run these entries, or stuck trying figure out way parse best possible , using process.start()?

thanks help!

i had similar project @ work. following code more-or-less wrote. can't guarantee it's foolproof seemed work registries tested against.

public static class processhelper {     const string registrysubkeyname =         @"software\microsoft\windows\currentversion\run";      public static void launchstartupprograms()     {         foreach (string commandline in getstartupprogramcommandlines())         {             string filename;             string arguments;              if (file.exists(commandline))             {                 filename = commandline;                 arguments = string.empty;             }             else if (commandline.startswith("\""))             {                 int secondquoteindex = commandline.indexof("\"", 1);                 filename = commandline.substring(1, secondquoteindex - 1);                  if (commandline.endswith("\""))                 {                     arguments = string.empty;                 }                 else                 {                     arguments = commandline.substring(secondquoteindex + 2);                 }             }             else             {                 int firstspaceindex = commandline.indexof(' ');                 if (firstspaceindex == -1)                 {                     filename = commandline;                     arguments = string.empty;                 }                 else                 {                     filename = commandline.substring(0, firstspaceindex);                     arguments = commandline.substring(firstspaceindex + 1);                 }             }              process.start(filename, arguments);         }     }      static ienumerable<string> getstartupprogramcommandlines()     {         using (registrykey key =             registry.currentuser.opensubkey(registrysubkeyname))         {             foreach (string name in key.getvaluenames())             {                 string commandline = (string) key.getvalue(name);                 yield return commandline;             }         }          using (registrykey key =             registry.localmachine.opensubkey(registrysubkeyname))         {             foreach (string name in key.getvaluenames())             {                 string commandline = (string) key.getvalue(name);                 yield return commandline;             }         }     } } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -