Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Run registry?

Status
Not open for further replies.

acjeff

Programmer
Aug 10, 2004
148
US
From Windows Run registry, there is a list of tasks specified for running at every time Windows starts up. I have an installer which adds a key to it so after installation and restart a VB6 program will open automatically. Then after the first time openning, the registry key must be removed so that next time it will not open again. The key is in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\test

where "test" is the new key I added and pointing to my VB application.

So how can I delete it from VB6 code? I tried
DeleteSetting "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "test"

but got an error.

Any thought?
 
Instead of adding your application to Run key, try the RunOnce key which lies next to the Run key in the same path.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

Windows executes the programs only once in this key and deletes the value automatically to prevent further executions.

Microsoft also recommend that installer and setup programs which continue after rebooting should execute their application from RunOnce key.

See the following article.
Run and RunOnce Registry Keys
 
The basic registry functions included in VB are, in fact, somewhat limited in that they actually only deal with entries under HKCU\Software\VB and VBA Program Settings

You need to either look at the real API calls or, simpler, RegDelete (along with Regread and RegWrite) in the Windows Script Host Object Model library that you can add as a project reference (sort of a middle ground of registry functionality)
 
Oh, I didn't realize the RunOnce key. That should work better. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top