Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 8th, 2012, 04:18 PM
vl654321 vl654321 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 128 vl654321 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 27 m 54 sec
Reputation Power: 3
How to start VBS script on over the LAN?

Hi,
I was wondering how to start a VBS script from my host on the LAN computer.
Thanks, vl123456

Reply With Quote
  #2  
Old March 8th, 2012, 08:51 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,233 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 15 m 56 sec
Reputation Power: 4445
The short answer is "you can't"

There are tools available that allow you to run programs on a remote machine, for example if you have ssh available you can fire off a command line program. And I think for windows sysinternals.com has a remote execution tool.
Comments on this post
Nilpo agrees!
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

Reply With Quote
  #3  
Old March 8th, 2012, 10:12 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: New Springfield, OH
Posts: 863 Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)  Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 5 Days 16 h 49 m 58 sec
Reputation Power: 1185
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Doug is correct. For security reasons there is no direct method of executing a command on a remote machine without using something like SSH or a tool such as PsExec. You can also use remote scripting. If you have proper permissions on the remote machine, you can run scripts from your current machine that execute on the remote machine.

Here's how it works. You run a script on your local machine that uses the FileSystemObject to copy a prewritten script file to a remote machine on your network. You'll need it's UNC path and proper credentials. Then, using WMI you can run the script (or any other command line for that matter) by starting a process on the target machine. A pure scripting example looks something like this.
vb Code:
Original - vb Code
  1. Set objFso = CreateObject("Scripting.FileSystemObject")
  2. objFso.CopyFile "myscript.vbs" "\\remotecomputer\c$\myscript.vbs"
  3.  
  4. strComputer = "remotecomputer"
  5. Set objWMIService = GetObject _
  6.     ("winmgmts:{impersonationLevel=impersonate}!\\" _
  7.         & strComputer & "\root\cimv2:Win32_Process")
  8. strCommandLine = "cmd.exe /c cscript.exe c:\myscript.vbs"
  9. errReturn = objWMIService.Create(strCommandLine, vbNull, vbNull, intProcessID)
__________________
Don't like me? Click it.

Scripting problems? Windows questions? Ask the Windows Guru!

Stay up to date with all of my latest content. Follow me on Twitter!

Help us help you! Post your exact error message with these easy tips!

Last edited by Nilpo : March 8th, 2012 at 10:15 PM.

Reply With Quote
  #4  
Old March 9th, 2012, 12:53 PM
vl654321 vl654321 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 128 vl654321 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 27 m 54 sec
Reputation Power: 3
First, thank you Doug and Nilpo for helping me!
I’m not a programmer, I’m just trying to make my life easier by automating some processes on the machines I’m working with. Basically I’m pulling evt logs and processing them. I found and modified a script for that. It stores decompressed EVT logs as a text file to the “host” and now I want to “call” my EVT.vbs script “from the host machine", I have all the credentials and I’ll try Nilpo’s script during weekend.
I do not want to “schedule” my EVT.vbs script on my local machines, I want to “cal it” from the “host”.
Thank you guys again. Vl123456

Reply With Quote
  #5  
Old March 9th, 2012, 01:02 PM
vl654321 vl654321 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 128 vl654321 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 27 m 54 sec
Reputation Power: 3
My bad!
Actually my EVT.vbs script does not store decompressed EVT.txt to the “host”. It stores locally in the “home” folder and then I’m using XCOPY batch file that pulls the EVT.text file from the “local” machines to the “host”.
Sorry about this, VL123456

Reply With Quote
  #6  
Old March 9th, 2012, 03:38 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: New Springfield, OH
Posts: 863 Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)  Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 5 Days 16 h 49 m 58 sec
Reputation Power: 1185
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
You're just reading event logs? Windows provides a tool for that. WMI (Windows Management Instrumentation) is capable of reading events and is designed to work on remote machines. That's the technology my script above is using to launch a process on the remote machine. From what it sounds like, WMI can do the whole process for you by design. Can you provide more details about what you're trying to find?

Reply With Quote
  #7  
Old March 9th, 2012, 11:55 PM
vl654321 vl654321 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 128 vl654321 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 27 m 54 sec
Reputation Power: 3
Thank you for your help Nilpo!
I'm pulling out "System" even logs (from the systems on LAN) then using special .exe and a .bat that decompresses the event logs and gives me only the events I'm interested in and stores them in the home dir on each machine as a TXT file. Then using Perl (I'm comfortable with Perl) I'm sorting/processing the EVTs and sending them to the server. The only missing part was the way to get these TXT files from locals to the host com.
I got VBS script (thanks to Google) to pull the EVT logs, I also modified it so it pulls EVTs, decompresses and stores it to the home dir on each local machine. I was thinking to use a VBS script to get the TXT files from the local machines. Actually today, I managed to transfer the TXT files from the local comps with Perl.
Code:
  my $cmd   = "copy C:\\fromhere C:\\tothere \/y";
      system ("$cmd") ;

I cannot use Perl on these local machines - not allowed.That is why I wanted to use VBS that I know nothing about.

Thank you again for you time Nilpo .
Vl123456

Reply With Quote
  #8  
Old March 10th, 2012, 01:07 AM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: New Springfield, OH
Posts: 863 Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)Nilpo User rank is General 3rd Grade (Above 100000 Reputation Level)  Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2Folding Points: 600856 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 5 Days 16 h 49 m 58 sec
Reputation Power: 1185
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
I guess what I'm getting at is that you don't need to do anything on the remote machines at all. You can do all of this from one location. A WMI script can poll remote machines for only the event information you want and store it locally...any way you want. Then you can use Perl or whatever you wish to crunch the data. For instance, let say I wanted to check every computer on my network for bluescreens and improper shutdowns. I could do something like this.
vb Code:
Original - vb Code
  1. arrComputers = Array("Computer1", "Computer2", "Computer3")
  2.  
  3. For Each strComputer in arrComputers
  4.     Set objWMIService = GetObject("winmgmts:" _
  5.     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  6.     Set colLoggedEvents = objWMIService.ExecQuery _
  7.         ("Select * from Win32_NTLogEvent Where Logfile = 'System'" _
  8.             & " and SourceName = 'SaveDump' " _ ' Stop Events
  9.             & " or EventCode = '6008'")         ' Improper Shutdown
  10.     For Each objEvent in colLoggedEvents
  11.         Wscript.Echo "Event date: " & objEvent.TimeGenerated
  12.         Wscript.Echo "Description: " & objEvent.Message
  13.     Next
  14. Next
The script can even be written to do the work asynchronously to speed it up a little.

Reply With Quote
  #9  
Old March 12th, 2012, 09:21 PM
vl654321 vl654321 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 128 vl654321 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 27 m 54 sec
Reputation Power: 3
Yes, as you can see I'm kind of using CMD (from Perl) to pull out my logs from each local machine.
I'm OK with that for now but I was wondering how I could call "my VBS" script on each machine from the host. I'm using Perl to manipulate the logs.

Thank you for your help Nilpo!
Vl123456

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > How to start VBS script on over the LAN?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap