Jump to content

Remotely enable RDP Problems


Recommended Posts

I am working on a script that will prompt the user for a computer name, then turn on RDP on the specified machine.

This works fine if I run it locally, specifying my own computer name. However, I can't make it change the registry value on other test machines. I have file and print sharing turned on, so I know that's not an issue. Any advice?

ps: I'm guessing the RunAsSet won't be necessary, because it will probably be domain admins running this anyway.

Below is the script that I'm using...

RunAsSet("userwhat", "what.local", "password")

$text = InputBox("RDP Enable", "Type in the computer name you wish to enable RDP")

RegWrite("\\"& $text &"\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server", "fDenyTSConnections", "REG_DWORD", 0)

Any input would be greatly appreciated.

Thanks,

mw

Link to comment
Share on other sites

I will advise you to read the remarks in the help file RunAsSet ( ["user", "domain", "password" [, options]] )

RunAsSet only work with Run() and RunWait() functions

You may be able to use command line REG.EXE together with Run() function instead of RegWrite().

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

@michaelwilliams,

Welcome to the AutoIt forum.

Danny has already mentioned the issue about the RunAsSet and has offered one of several ways to work around that... but you mentioned that you might not even need that line - so, let's leave that issue aside for now and work on your RegWrite line of code. Try this script and see if the "@error" info helps you find your problem:

$text = InputBox("RDP Enable", _
        "Type in the computer name you wish to enable RDP")
RegWrite("\\" & $text & _
        "\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server", _
        "fDenyTSConnections", "REG_DWORD", 0)
MsgBox(0, "@error", @error)

;~  0 if no errors.... I think
;~  1 if unable to open requested key
;~  2 if unable to open requested main key
;~  3 if unable to remote connect to the registry
;~  -1 if unable to open requested value
;~  -2 if value type not supported

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

@michaelwilliams

Maybe this is something that can you get started

#include <GUIConstants.au3>
$Computer = InputBox("RDP Enable", "Type in the computer name you wish to enable RDP")

$oRDP = ObjCreate("MsTscAx.MsTscAx") 
GUICreate("Embedded RDP control Test", 640, 480, -1 , -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oRDP, 10, 10, 620, 460)
GUICtrlSetStyle ( $GUIActiveX,  $WS_VISIBLE )   
GUICtrlSetResizing ($GUIActiveX,$GUI_DOCKAUTO)

GUISetState()

$oRDP.Server = $Computer
$oRDP.Domain = "Mydom"
$oRDP.UserName = "administrator"
$oRDP.AdvancedSettings2.ClearTextPassword = "HH90"

$oRDP.FullScreen = false
$oRDP.AdvancedSettings2.RedirectDrives = False
$oRDP.AdvancedSettings2.RedirectPrinters = False
$oRDP.AdvancedSettings2.RedirectPorts = False
$oRDP.AdvancedSettings2.RedirectSmartCards = False

$oRDP.StartConnected = True
$oRDP.Connect()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

$oRDP.Disconnect
GUIDelete()
Exit

Enjoy!!

ptrex

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...