Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


running cmd prompt remotely

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,24015
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> running cmd prompt remotely
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 running cmd prompt remotely - 7/25/2005 5:39:14 AM   
  Brian32

 

Posts: 14
Score: 0
Joined: 7/13/2005
Status: offline
Is there a way to run commands from the cmd prompt on a remote PC using vbscript? Can this be done witout copying the script to the remote PC or using other utilities (PsExec, etc)?

This works only for the local PC:

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "dir"

Thanks.
 
 
Post #: 1
 
 RE: running cmd prompt remotely - 7/25/2005 11:56:48 AM   
  Country73


Posts: 732
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
To run DIR against another machine you can use this:
'-------------------------------------------------------------------------------------------
strComputer = "Machine Name"
strShare = "The Share"

Set objShell = CreateObject("Wscript.Shell")
Set objExec = objShell.Exec("cmd /c dir \\" & strComputer & "\" & strShare)
   val = val & objExec.StdOut.ReadAll
   wscript.echo val
'------------------------------------------------------------------------------------------

If you're actually wanting to run an executible/script/whatever, then you're going to need to use something like PSEXEC in your script. Without, you'll still be able to run those items, but it will be ran against the machine your actually running the script from.

(in reply to Brian32)
 
 
Post #: 2
 
 RE: running cmd prompt remotely - 7/25/2005 1:13:02 PM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
http://www.spoogenet.com/index.php?module=article&view=15&5cbaa9d36385e275f0a415eb9b827618=bd43a81d7239dbbe5910db6034a38fed

_____________________________

If you can conceive it you can achieve it
___________________________________

www.spoogenet.com

(in reply to Country73)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> running cmd prompt remotely Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts