开发者

Registry key editing vb6 startup

开发者 https://www.devze.com 2022-12-25 04:43 出处:网络
Is it possible that someone here could explain how to use this code. Please keep in mind i am a complete amateur, so simplifications may be needed.

Is it possible that someone here could explain how to use this code. Please keep in mind i am a complete amateur, so simplifications may be needed.

Private Const cPGM = "C:\VB Forum\startup\Example.exe"

Dim oShell As IWshShell_Class
Set oShell = New IWshShell_Class
oShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyVBApp", _
               cPGM, "REG_SZ"

How开发者_如何学JAVA exactly is this code used? Is it saved as an .exe file and ran or what? Thanks for your prompt reply and informational feedback.


All this code does is add a value to the registry. It adds an item to the key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

with the name MyVBApp, and the value C:\VB Forum\startup\Example.exe

As it states in the article, this registry entry will cause the program C:\VB Forum\startup\Example.exe to launch automatically at system startup.

In order to use this code it does somehow have to be executed which, of course, requires an executable. If you want to see this code in action, the simplest thing to do would be to create a new "Standard EXE" project, add a reference to the Windows Script Host Object Model, paste the code into the Form_Load event, then run the app. Look at this registry key and you'll see this new entry. Be sure and delete it though because I assume you don't have some executable named C:\VB Forum\startup\Example.exe that you wish to run every time Windows starts, do you?

0

精彩评论

暂无评论...
验证码 换一张
取 消