Home All Groups Group Topic Archive Search About

vb.net - RunOnce key not executing at startup

Author
13 Dec 2006 9:21 PM
lukecooley
I am new to coding in vb.net and I am trying to add a registry value in
the runonce key.  The key is added correctly, as I can see it when
going directly into the registry after executing my code, but when I
reboot, the value (aka the .cmd file) is not executed and the string
value is not deleted from the registry (at
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce).
Here is the code I am using to create the key:
Dim key As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce",
True)
key.SetValue("MWAClean", "c:\sma\mwaclean\mwaclean.cmd")

Is there something wrong with the code I'm using to create the key that
is not allowing XP to see it on startup...or is there something else
going on here with windows????

Any help will be greatly appreciated,

Luke

Author
13 Dec 2006 10:10 PM
NewScience
Try putting the execution of the .cmd in a .bat file and add that to the
registry RunOnce.
That way you can debug the batch file when the system reboots by using echo
commands.

<lukecoo***@gmail.com> wrote in message
Show quoteHide quote
news:1166044919.450526.52610@73g2000cwn.googlegroups.com...
>I am new to coding in vb.net and I am trying to add a registry value in
> the runonce key.  The key is added correctly, as I can see it when
> going directly into the registry after executing my code, but when I
> reboot, the value (aka the .cmd file) is not executed and the string
> value is not deleted from the registry (at
> HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce).
> Here is the code I am using to create the key:
> Dim key As Microsoft.Win32.RegistryKey =
> Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce",
> True)
> key.SetValue("MWAClean", "c:\sma\mwaclean\mwaclean.cmd")
>
> Is there something wrong with the code I'm using to create the key that
> is not allowing XP to see it on startup...or is there something else
> going on here with windows????
>
> Any help will be greatly appreciated,
>
> Luke
>
Author
14 Dec 2006 5:06 PM
coolhand400
Debugging got me going in the right direction...just an error in the
batch file.
Thanks for your help


NewScience wrote:
Show quoteHide quote
> Try putting the execution of the .cmd in a .bat file and add that to the
> registry RunOnce.
> That way you can debug the batch file when the system reboots by using echo
> commands.
>
Author
13 Dec 2006 11:07 PM
Jon
I have it on good authority that <lukecoo***@gmail.com> said in
Show quoteHide quote
news:1166044919.450526.52610@73g2000cwn.googlegroups.com...
>I am new to coding in vb.net and I am trying to add a registry value in
> the runonce key.  The key is added correctly, as I can see it when
> going directly into the registry after executing my code, but when I
> reboot, the value (aka the .cmd file) is not executed and the string
> value is not deleted from the registry (at
> HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce).
> Here is the code I am using to create the key:
> Dim key As Microsoft.Win32.RegistryKey =
> Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce",
> True)
> key.SetValue("MWAClean", "c:\sma\mwaclean\mwaclean.cmd")
>
> Is there something wrong with the code I'm using to create the key that
> is not allowing XP to see it on startup...or is there something else
> going on here with windows????
>
> Any help will be greatly appreciated,
>
> Luke
>

You've pretty much established that your vb.net code is ok.

You may need to include a link to cmd.exe or %comspec% to precede your
command string.

--
Jon