none
Need help writing vbscript to run exe with parameter RRS feed

  • Question

  • I need to get the SNMP service installed on a Windows Server 2008 using SCCM, so unfortunately using PowerShell is out of the question because 2008 only has PSv1 installed (I can't upgrade to v2 or v3), as that would have been my preferred method of accomplishing this. So this leaves me having to use either vbscript or jscript. So I thought vbscript would be the way to go.

    Here's the command that ultimately needs to run

    %systemroot%\system32\servermanagercmd.exe -install SNMP-Service

    After several hours of research (because I have absolutely no experience with vbscript), the below is all that I have, but still can't seem to get it working.

    Set WshShell = WScript.CreateObject("WScript.Shell") 
    WshShell.Run("%systemroot%\system32\servermanagercmd.exe -install SNMP-Service")


    Wednesday, December 23, 2015 4:06 PM

Answers

  • Hi,

    Try it this way:

    Set WshShell = WScript.CreateObject("WScript.Shell")
    runCmd = "%systemroot%\system32\servermanagercmd.exe -install SNMP-Service"
    WshShell.Run "cmd /c " & runCmd, 0, True


    • Marked as answer by Thomas Garrity Wednesday, December 23, 2015 4:29 PM
    Wednesday, December 23, 2015 4:14 PM

All replies

  • Hi,

    Try it this way:

    Set WshShell = WScript.CreateObject("WScript.Shell")
    runCmd = "%systemroot%\system32\servermanagercmd.exe -install SNMP-Service"
    WshShell.Run "cmd /c " & runCmd, 0, True


    • Marked as answer by Thomas Garrity Wednesday, December 23, 2015 4:29 PM
    Wednesday, December 23, 2015 4:14 PM
  • Awesome, that worked. Thanks!
    Wednesday, December 23, 2015 4:29 PM
  • Cheers, you're very welcome.

    Wednesday, December 23, 2015 4:41 PM