MSFN Forum: VBS Script to edit Registry - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

VBS Script to edit Registry Rate Topic: -----

#1 User is offline   frostbite1000 

  • Group: Members
  • Posts: 1
  • Joined: 23-September 05

Posted 23 September 2005 - 04:13 PM

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


#2 User is offline   gunsmokingman 

  • MSFN Addict
  • Group: Super Moderator
  • Posts: 1,991
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 23 September 2005 - 05:50 PM

frostbite1000, on Sep 23 2005, 11:13 PM, said:

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
<{POST_SNAPBACK}>


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

Quote

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


#3 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,117
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 24 September 2005 - 03:43 AM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy