Go to Post There is something completely respectful and amazing to see FIRST teams who have members go through 4 years of the program without winning a single competition or even a single award. Those are the teams that are looked at by others and respected for what they do. - fuzzwaz [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-06-2004, 10:33
Jeff Waegelin's Avatar
Jeff Waegelin Jeff Waegelin is offline
El Jefe de 148
AKA: Midwest Refugee
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Aug 2001
Rookie Year: 2001
Location: Greenville, TX
Posts: 3,132
Jeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond repute
Remote Program Execution in Visual Basic

So, I'm trying to write a program in Visual Basic that will execute a batch file on 5 remote PCs on a network. Does anyone know how I can do this? When I try to run the batch files now, I can access them over the network, but they execute on my PC, not the satellite PCs. I need some code that will let me access the remote PCs, either all at once or one at a time, and run the command to start the BAT on the remote PCs. Can anyone help me with this?
__________________
Jeff Waegelin
Mechanical Engineer, Innovation First Labs
Lead Engineer, Team 148 - The Robowranglers
  #2   Spotlight this post!  
Unread 09-06-2004, 10:46
Greg's Avatar
Greg Greg is offline
Registered User
FRC #1075 (Sinclair Sprockets)
Team Role: College Student
 
Join Date: Nov 2002
Rookie Year: 2003
Location: Whitby, Ontario, Canada
Posts: 108
Greg is on a distinguished road
Send a message via ICQ to Greg Send a message via MSN to Greg
Re: Remote Program Execution in Visual Basic

Well, there are several ways to do this. One is to write a VB app that will run in IIS on the target machine. The application will create a web page that you can go to to trigger the job. However, this requires setting up web servers on the machines, and you probably dont want to have 5 web servers

Another way would be to write a program that uses Winsock. On the machines where you want to run the batch you set up a "server" program that opens a specific port and waits for a command. It should start with Windows. On your machine you have a "client" program that can connect to that program on that port and send it the command. You'll probably also want a password of some sort. There's quite a number of Winsock tutorials online.
  #3   Spotlight this post!  
Unread 09-06-2004, 10:56
Jeff Waegelin's Avatar
Jeff Waegelin Jeff Waegelin is offline
El Jefe de 148
AKA: Midwest Refugee
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Aug 2001
Rookie Year: 2001
Location: Greenville, TX
Posts: 3,132
Jeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond reputeJeff Waegelin has a reputation beyond repute
Re: Remote Program Execution in Visual Basic

Quote:
Originally Posted by Greg
Well, there are several ways to do this. One is to write a VB app that will run in IIS on the target machine. The application will create a web page that you can go to to trigger the job. However, this requires setting up web servers on the machines, and you probably dont want to have 5 web servers

Another way would be to write a program that uses Winsock. On the machines where you want to run the batch you set up a "server" program that opens a specific port and waits for a command. It should start with Windows. On your machine you have a "client" program that can connect to that program on that port and send it the command. You'll probably also want a password of some sort. There's quite a number of Winsock tutorials online.
Can you point me towards any tutorials you think are better than others?
__________________
Jeff Waegelin
Mechanical Engineer, Innovation First Labs
Lead Engineer, Team 148 - The Robowranglers
  #4   Spotlight this post!  
Unread 09-06-2004, 11:34
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Remote Program Execution in Visual Basic

I do not believe you can have the files execute w/o something running on the other end.

MSDN has plenty of info.

I specialize in VB 6.0 (not .NET), so what I say will mostly apply to that.

The Winsock control is probably the best way to do this. the Inet will work too, but is more geared for getting documents off the WWW. Both only come with Profesional and Enteprise Editions. I haven't actually done this yet, but I will try to give a simple tutorial based on the subs.

On the server:
  1. Set the LocalPort and Protocal properties to what ever.
    For each client:
  2. Set the RemoteHost, RemoteHostIP, and the RemotePort properties to the client.
  3. Call Connect to connect to the remote computer; Wait for the Connect event.
  4. Call SendData to tell the client go.
  5. Wait for the SendComplete event.
  6. If there is a response in ur packet format, wait for that.
  7. Call Close

On each client:
  1. Set the LocalPort and Protocal properties to what ever.
  2. Set the RemoteHost, RemoteHostIP, and the RemotePort properties to the server.
  3. Call Listen, wait for the ConnectionRequest event, then call Accept to connect.
  4. Wait for the DataArrival event.
  5. Call GetData to get the data, then parse it (own code).
  6. If there is a response in ur packet format, call SendData to send the response.
  7. Run the file.

I don't think Shell() runs bats, but if you add Shell32.dll to your references, you can use the Shell object to run anything. (Verbs)
  #5   Spotlight this post!  
Unread 10-06-2004, 09:03
wun's Avatar
wun wun is offline
Registered User
AKA: David Wolever
#0865 (Warp7)
Team Role: Programmer
 
Join Date: Dec 2003
Rookie Year: 2001
Location: Toronto
Posts: 84
wun will become famous soon enough
Send a message via AIM to wun Send a message via MSN to wun
Re: Remote Program Execution in Visual Basic

Quote:
Originally Posted by Astronouth7303
I do not believe you can have the files execute w/o something running on the other end.
Ah, but this is windows we are talking about!
Of corse you can run programs on a remote machine without installing anything on it! Thats how the blaster worm got so big! You can see if by going on any 2k box and using the command shutdown -i (-i is for interface, you can use --help if you wanna do it from the terminal).
I have a similar situation at my school, and we solved it in a couple of ways.
One of them was dameware (http://www.dameware.com/). Its not VB, but basically it lets you control lots of computers on your network.
The second way I solved the problem through VB was very simple, but probably not the most efficient. I simply wrote a program that would check a text file on the file-server ever minute or so, and if there was a 1 in it, it would 'lock' the computer it was on, and if it was a 0, it would 'un lock' the computer.
I realize this is an extremely inefficient way of doing things, but it was only took me a couple of hours to do.
I'm not sure if either of these solutions will work for you, but I thought I might as well mention them.
If you do get something working with winstock I would be interested in seeing it (if you dont mind), because I want to start playing around with it too (to write a similar applications).
__________________
Help Microsoft stop piracy. Use Linux!

I have three gmail invitations, message me if you want one
  #6   Spotlight this post!  
Unread 10-06-2004, 21:54
jdong jdong is offline
Linux Nerd
AKA: John D
#0245 (Adam-Bots)
Team Role: Programmer
 
Join Date: Apr 2004
Location: Rochester, MI
Posts: 98
jdong will become famous soon enoughjdong will become famous soon enough
Re: Remote Program Execution in Visual Basic

Ok, you need a daemon (that's "server" for you windows folks) listening on a TCP port, for commands to execute. Upon receiving them, it executes them.


Or, you can specialize the program, to wait on a TCP port for a textfile, keep reading until reaching a special character, save that into a .bat file, then execute....


But of course, security issues
__________________
John Dong
Co-Captain, Webmaster / Programmer
Team 245 -- Rochester Adams Robotics
  #7   Spotlight this post!  
Unread 14-06-2004, 21:15
Venkatesh Venkatesh is offline
Registered User
FRC #0030
 
Join Date: Jan 2003
Rookie Year: 2002
Location: USA
Posts: 260
Venkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to beholdVenkatesh is a splendid one to behold
Re: Remote Program Execution in Visual Basic

I have had to do something like this before, but I didn't use Visual Basic.

When I had to have a program run on multiple systems, I write small batch files and install them on all the target systems. These batch files go onto the network and get a list of commands to do, and then execute them.

ex: ---------------------------
@ECHO OFF
NET USE * /d
NET USE N: \\inferno\list /Y
C:
CD\
COPY N:\1.txt C:\1.bat
CALL C:\1.bat
DEL C:\1.bat
REM Command Done

I would put the requisite commands into 1.txt on a server of sorts. Inferno is my server, and list is a special share where I put 1.txt.
__________________
-- vs, me@acm.jhu.edu
Mentor, Team 1719, 2007
Team 30, 2002-2005
Closed Thread


Thread Tools
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
White Paper Discuss: 2004 Visual Basic 6 Dashboard Control CD47-Bot Extra Discussion 2 01-02-2005 01:56
Visual Basic dddriveman Programming 12 20-03-2004 13:03
Help programming in Visual Basic xxlshortys Programming 0 06-04-2003 08:54
Computer Graphics and Visual Basic Programing Gope General Forum 0 26-10-2002 13:44
Anyone looking for more program space? archiver 2001 13 24-06-2002 02:20


All times are GMT -5. The time now is 22:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi