Jump to content

Recommended Posts

Posted

Hey Guys, I need a Visual Basic Script that can Edit the registry. I want to add a program to the startup list from a script. If someone could write that for me that would be great [With an example program of where the real one should go] Thanks :D


Posted
Hey Guys, I need a Visual Basic Script that can Edit the registry. I want to add a program to the startup list from a script. If someone could write that for me that would be great [With an example program of where the real one should go] Thanks :D

This place a short cut in the all user start up menu it set to open

notepad

Option Explicit

Dim Act, Scut, WD, All_UP  : Set Act=CreateObject("Wscript.Shell")

ALL_UP = Act.ExpandEnvironmentStrings("%AllUsersProfile%") : WD = Act.ExpandEnvironmentStrings("%windir%")

Set Scut = Act.CreateShortcut(ALL_UP & "\Start Menu\Programs\Startup\SCNotepad.lnk")

Scut.TargetPath = WD & "\Notepad.exe"

Scut.WorkingDirectory = WD

Scut.Save

Posted

If you are wanting to add to the Run section of the registry, then something like this perhaps:

Const constHKEY_LOCAL_MACHINE = &H80000002
Const constComputer = "."

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
 constComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
strValueName = "MyVal"
strValue = "Drive:\PathTo\MyFile.ext"
objReg.SetStringValue constHKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue

You would simply need to change the strings 'strValueName' and 'strValue' to your specific needs

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...