vb.net - RunOnce key not executing at startup

L

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
 
N

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.
 
J

Jon

I have it on good authority that said:
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.
 
C

coolhand400

Debugging got me going in the right direction...just an error in the
batch file.
Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top