none
wsf to enable remote desktop on Windows 2012 R2 RRS feed

  • Question

  • I have a simple wsf that enable remote desktop on windows 2012.  I have no problem setting the registry value, but my netsh command doesn't seem to work, and with no error

    Function ZTIProcess()

        iRetVal = Success
        ZTIProcess = iRetval

        oLogging.CreateEntry "Configure - Enable Remote Desktop: Starting", LogTypeInfo

        oShell.RegWrite "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\fDenyTSConnections",0 ,"REG_DWORD"
        oShell.RegWrite "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\UserAuthentication",1 ,"REG_DWORD"
        iRetVal = oShell.Run("netsh advfirewall firewall set rule group='Remote Desktop' new enable=Yes")

        if (iRetVal = 0) or (iRetVal = 3010) then
            ZTIProcess = Success
        Else
        ZTIProcess = Failure
        End If

        oLogging.CreateEntry "Configure Remote Desktop: Return code value = " & iRetVal, LogTypeInfo
        oLogging.CreateEntry "Configure Remote Desktop: Completed Enabling Remote Desktop", LogTypeI

    End Function

    When I try to run the netsh command [netsh advfirewall firewall set rule group='Remote Desktop' new enable=Yes] in an elevated command prompt on the server, it works without issue, so I presume the syntax is correct.  Do I need to set elevated privilege within my task sequence to make this work?

    Tuesday, August 12, 2014 3:10 PM

Answers

  • It will set the registry value but netsh never kicks off.  I fix the problem by going completely with PowerShell.  Still weird why the netsh never executed
    Wednesday, August 20, 2014 1:25 PM

All replies

  • Do I need to set elevated privilege within my task sequence to make this work?

    What happens when you try it?


    -- Bill Stewart [Bill_Stewart]

    Tuesday, August 12, 2014 3:37 PM
    Moderator
  • It will set the registry value but netsh never kicks off.  I fix the problem by going completely with PowerShell.  Still weird why the netsh never executed
    Wednesday, August 20, 2014 1:25 PM