Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Remotely Enable Remote Desktop
 

Vbscript / Operating System / Remotely Enable Remote Desktop

Enable remote desktop on a remote computer without directly editing the registry.


strComputer = InputBox ("Target Computer", "Enable Remote Desktop", default, 100, 100)
strUser = InputBox ("Username (DOMAIN\Administrator)", "Enable Remote Desktop", default, 100, 100)
strPass = InputBox ("Password", "Enable Remote Desktop", default, 100, 100)


strNameSpace = "root\cimv2"
strClass = "Win32_TerminalServiceSetting"

Const ENABLE_CONNECTIONS = 1
Const DISABLE_CONNECTIONS = 0

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer (strComputer, strNameSpace, strUser, strPass)

Set colClass = objSWbemServices.ExecQuery("Select * from " & strClass)
For Each objItem in colClass
   intErr = objItem.SetAllowTSConnections(ENABLE_CONNECTIONS)
Next

If intErr = 0 THEN
   Wscript.echo "Remote Desktop is now enabled on " & strComputer
Else
   Wscript.echo "There was a problem enabling Remote desktop on " & strComputer
End If





Please note that a disclaimer applies to any code on this page.
 
   Actions
  Go Back
  Bookmark
  Print Page


   Menu
 
- Links
- Reference
- Script Editors
- Tutorials
- Vbscript
     - Active Directory
     - Exchange
     - Files And Folders
     - General
     - Ms Office
     - Operating System
          - Add Remove Windows Server 2003 Components
          - Add Remove Windows Vista Components
          - Add Remove Windows Xp Components
          - Autologon And Runonce
          - Change Display Resolution
          - Change Location I386 Setup Files
          - Change Offline Folder Cache Location
          - Dell Bios Set Boot Device Order
          - Dell Bios Set Configuration Settings
          - Dell Bios View Configuration Settings
          - Dell Bios View Device Boot Order
          - Disable Vista User Account Control
          - Enumerate Cd Drives
          - Enumerate Computer Drives
          - Enumerate Disk Volumes
          - Enumerate Registry Keys
          - Flush Remote Dns Cache
          - Get Domain Name
          - Get Machine Hardware Model
          - Read Registry Key
          - Remotely Enable Remote Desktop
          - Rename Computer
          - Rename Dell Machine By Service Tag
          - Set Internet Explorer Homepage
          - Set Random Desktop Wallpaper On Startup
          - Set Vista Network Location Category
          - Start And Stop A Service
          - Vista Disable Ipv6
          - Windows Login Timer
     - Processes And Services
     - Text Processing
     - User Interaction
     - Web Servers