How to Connect to a Remote Computer in VBScript

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.

Things You'll Need

  • Text editor
Show More

Instructions

  1. Validate Remote Computer Is Available

    • 1

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

    • 2

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

    • 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

      Verify that the system returns with four reply messages.

    Write and Run a Connection Script

    • 5

      Open your text editor.

    • 6

      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 )

      next

      wscript.Echo "Terminal Services has been enabled."

    • 7

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

    • 8

      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."

    • 9

      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 & 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.

Related Searches:

References

Resources

Comments

You May Also Like

Related Ads

Featured