Enable remote desktop on client side and connect

CatOnRug solve, automate, speed up
EnableRDAndConnect.au3
$cName = InputBox('Remote assistance','Type a computer name to connect:')

$ts = "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server"

if StringLen($cName) > 0 Then
RunWait('psexec \\' & $cName & ' reg add ' & $ts & ' /v AllowTSConnections /t REG_DWORD /d 1 /f')
RunWait('psexec \\' & $cName & ' reg add ' & $ts & ' /v fDenyTSConnections /t REG_DWORD /d 0 /f')
RunWait('psexec \\' & $cName & ' reg add ' & $ts & ' /v fAllowToGetHelp /t REG_DWORD /d 1 /f')

RunWait(@ComSpec & " /c " & 'start /w mstsc /v:' & $cName,'','')

Else 
MsgBox(0,'Info','No computername was entered. Exiting.. Bye. Have a nice day!')

EndIf
DisableRD.au3
$cName = InputBox('Remote assistance','Type a computer name to disable Remote Desktop:') 

$ts = "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server"

if StringLen($cName) > 0 Then
RunWait('psexec \\' & $cName & ' reg add ' & $ts & ' /v AllowTSConnections /t REG_DWORD /d 0 /f')
RunWait('psexec \\' & $cName & ' reg add ' & $ts & ' /v fDenyTSConnections /t REG_DWORD /d 1 /f')
RunWait('psexec \\' & $cName & ' reg add ' & $ts & ' /v fAllowToGetHelp /t REG_DWORD /d 0 /f')

Else
MsgBox(0,'Info','No computername was entered. Exiting.. Bye. Have a nice day!')

EndIf

No comments:

Post a Comment