How to Connect to a Remote Computer in VBScript

Written by jon guenther
  • Share
  • Tweet
  • Share
  • Email

You can use VBScript to connect to a remote computer within either a business network or other secure, internal network. Your ability to connect to a remote computer using a VBScript file will require the computer to be turned on and to have an IP address or domain name to make the connection within a network. Once you've established those prerequisites, you will write the script to test your connection.

Skill level:

Things you need

  • Text editor

Show MoreHide


  1. 1

    Click the "Start" button, and then click "Run."

  2. 2

    Type "cmd /k" in the Open text box and click the "OK" button.

  3. 3

    Type the following at the command prompt, where "computer_name" is either the IP address or the domain name of the computer: "ping computer_name".

  4. 4

    Verify that the system returns with four reply messages.

  1. 1

    Open your text editor.

  2. 2

    Type the following code:

    machine = InputBox("Enter Name of the Remote Computer:","Prompt!")

    cimv2_string = "WINMGMTS:" & "\" & machine & "\root\cimv2"

    query = "select * from Win32_TerminalServiceSetting"

    value_to_set = 1 ' 0=off, 1=on

    set cimv2 = GetObject( cimv2_string )

    set items = cimv2.ExecQuery( query )

    for each item in items

    item.SetAllowTSConnections( value_to_set )


    wscript.Echo "Terminal Services has been enabled."

  3. 3

    Save the file with a .vbs extension to computer's hard drive.

  4. 4

    Double-click the .vbs file, and enter the computer name in the text box provided. Verify that it returns with the message "Terminal Services has been enabled."

  5. 5

    Attempt to connect to the remote computer using Remote Desktop Protocol application in Windows. If you are able to log in, then the remote connection VBScript has executed correctly.

Tips and warnings

  • Be certain to ping a remote computer and ensure that it is on before attempting to connect.
  • Firewalls and security software can prevent you from connecting to a remote computer using VBScript.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.