Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

vbs scripting question?

Options
  • 08-03-2006 9:19pm
    #1
    Registered Users Posts: 68 ✭✭


    I would like to have standard users execute a single script that will modify the registry as shown below. at the moment the registry modifications only work when the script is executed using the admin account, can anyone help???:(

    I would prefer to embed the admin user name and password if possible.
    I've been looking at the runas command and playing with WMI:

    Set objLocator = CreateObject( "WbemScripting.SWbemLocator" )
    Set objWMIService = objLocator.ConnectServer ( strComputer, "root/cimv2", strUser, strPassword )
    objWMIService.Security_.impersonationlevel = 3
    :eek:

    I dont want to prompt for user input.



    on error resume next

    Dim objWMIService, objItem, objService
    Dim colListOfServices, strComputer, strService, intSleep, rkeyval1,
    strComputer = "."
    intSleep = 5000
    set SHELL = CreateObject("WScript.Shell")
    rkeyval1 = "HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\"


    regval1 = rkeyval1 & "WUServer"
    regval2 = rkeyval1 & "WUStatusServer"

    Shell.RegWrite regval1,"http://wsussrv001", "REG_SZ"
    Shell.RegWrite regval2,"http://wsussrv001", "REG_SZ"


    ' NB strService is case sensitive.
    strService = " 'wuauserv' "
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
    Set colListOfServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where Name ="_
    & strService & " ")
    For Each objService in colListOfServices
    objService.StopService()
    WSCript.Sleep intSleep
    objService.StartService()
    Next

    wscript.echo "WINDOWS UPDATE SETTINGS MODIFIED"


Comments

  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 90,855 Mod ✭✭✭✭Capt'n Midnight


    I'd use psexec.exe (sysinternals) and reg.exe (microsoft) to change remote reg settings. Especially since those settings are a one off.

    What would be handier would be a way for a server to initiate a script on the server with admin rights when someone logs in.


  • Registered Users Posts: 6,762 ✭✭✭WizZard


    I'd go with Capt'n Midnight's idea of psexec and reg.exe

    However if you really want to use VBScript and impersonation then this link should give you a lot of help.

    <edit>Whoops, on rereading I see my link is not going to help a lot. Sorry.

    Also, wouldn't a domain group policy be more effective for this (SUS)?
    </edit>


  • Registered Users Posts: 68 ✭✭alancool


    tanx folks but i looked at psexec and for packaging reasons (the script will be packaged using iexpress) i cant get it to work.

    WiZzard: unfortunately i cant correct the problem using gpo either, sensible suggestion though.

    if you have any other ideas i'd appreciate it tanx

    ac:cool:


Advertisement