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?
精彩评论