Kaseya Community

netsh command not executing in script

  • The following fails to execute with VSA script, but works fine in elevated command prompt:


    Script Name: Configure Proxy
    Script Description: Set IE Proxy Settings
    Configure Proxy Server Address
    Set winHTTP Settings

    IF True

    Execute Shell Command     
    Parameter 1 : netsh winhttp set proxy     
    Parameter 2 : 1         
    OS Type : 0 ELSE

    How can I troubleshoot?  I do not see any entries in AgentMon.txt.

    Script is set to run as system, but also fails when set to run as administrator.  Kaseya agent account is running as domain admin.

    Also, attempts to execute VBS to set proxy also fail. 

    Please advise on best way to script to netsh winhttp set proxy and how to troubleshoot why current script is failing.

    Thank you in advance Cool

  • do you have this problem if you just do a "netsh winhttp show proxy"?

  • Interesting:

    netsh winhttp show proxy >> proxy.out

    displays the proper setting.

    It appears that kaseya is executing the command under a different user space than currently logged in user.  When running:

    netsh winhttp show proxy

    at command prompt, no proxy is shown, but appears in kaseya output file.

    Can anyone provide some insight?

  • By default Execute Shell Command runs as System, you can make it run as logged on user however if nobody is logged on then it will run as System.

    So if your script is dependant on running as the logged on user you will need to make it check if somebody is logged on first

  • I figured out the problem is since 32-bit agent is running on 64-bit system, C:\windows\syswow64\netsh.exe is being executed.

    Since I'm redirecting Windows Update (64-bit) through proxy, I need c:\windows\system32\netsh.exe to be executed.

    Can anyone advise on how to execute c:\windows\system32\netsh.exe from VSA script?

    I'm currently testing different methods like:

    cmd  /c "%windir%\sysnative\netsh winhttp set proxy" >> C:\temp\netsh.out

    Are quotes in proper locations?