473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

vb.net - RunOnce key not executing at startup

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\Run Once).
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

Dec 14 '06 #1
3 7127
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.

<lu********@gmail.comwrote in message
news:11*********************@73g2000cwn.googlegrou ps.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\Run Once).
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

Dec 14 '06 #2
Jon


I have it on good authority that <lu********@gmail.comsaid in
news:11*********************@73g2000cwn.googlegrou ps.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\Run Once).
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

Dec 14 '06 #3
Debugging got me going in the right direction...just an error in the
batch file.
Thanks for your help
NewScience wrote:
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.
Dec 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Yoni Gibbs | last post by:
Hi, Once an assembly has been downloaded into the GAC, is it possible to execute it locally somehow? e.g. if I download an exe into the GAC, can the client PC simply run this assembly directly,...
1
by: Dmitri Shvetsov | last post by:
Hi, My C# application works under administrative account but can't write to: HKML\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce What can I do to write there? Dmitri
15
by: Chakkaradeep | last post by:
Hi all, i have written a Service,now i want to execute another application (for eg;calc.exe) in the service....how will i perform it??... i tried using this.... /**************Executing a...
2
by: Anthony Nystrom | last post by:
I need to exceute a method in a form from another form... Both forms will always be open so I don't have to worry about that... I just need to call the method... Please help... Source please...
0
by: Bruceneedshelp | last post by:
My application starts logging and executes shell commands on startup. The application runs fine, except when it executes at boot time. In other words when I make it a "startup" application on my...
2
by: Pete Vickers [MVP] | last post by:
Hi, I have a project, that doesn't appear to process frmMain at all - I break at form_load, and nothing happens. The form shows, but has done no processing in the form load. I have tried having...
8
by: lovecreatesbea... | last post by:
K&R 2, sec 2.4 says: If the variable in question is not automatic, the initialization is done once only, conceptually before the program starts executing, ... . "Non-automatic variables are...
0
by: IanB | last post by:
I've just installed IE7 as part of Windows Update on this computer (Compaq AMD64X2 4200+ 2Gb) but it will not run the opening link: http://runonce.msn.com/runonce2.aspx just leaving me with a...
3
by: amolbehl | last post by:
Hi, I have a written 2 VB programs, "startup.exe" and a "mainProgram.vbp" now I need to invoke the "startup.exe" via mainProgram.vbp and send a parameter to the startup.exe as well. Does...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.