none
Create Registry Key in a hive with VBS RRS feed

  • Question

  • All

    I'm trying to create a key and a string value in a hive.  I've already been searching the internet and I came to next code.  However, the key is not created.  So what's going wrong?

    set objshell = CreateObject("Wscript.shell")
    strComputer = "."
    strKeyPath1 = "\Tempdefault\software\microsoft\windows\currentversion\RunOnce"
    objshell.Exec ("%comspec% /k reg.exe load HKU\Tempdefault c:\Docume~1\Defaul~1\ntuser.dat")
    Set objReg = GetObject("winmgmts:" & _
    "{impersonationLevel=Impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
    objreg.createkey HKU,strKeyPath1
    objReg.SetStringValue HKEY_USERS,strKeyPath1,"RunOnce","C:\Windows\System32\GroupPolicy\User\Scripts\Logon\run_settings_creating_new_user_profile.bat"
    objshell.Exec ("%comspec% /k reg.exe unload HKU\Tempdefault")

    Thanks

    Ino

    • Moved by Bill_Stewart Friday, July 27, 2018 4:17 PM This is not "debug/fix/rewrite my script for me" forum
    Wednesday, April 18, 2018 9:21 AM

All replies