Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

vbs scripting question?

  • 08-03-2006 09:19PM
    #1
    Registered Users, Registered Users 2 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: 96,050 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, Registered Users 2 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, Registered Users 2 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