Srvany & Batch Files: Stopping The .exe

SoulAssassin

Diamond Member
Feb 1, 2001
6,135
2
0
So here's the deal, we have some batch files that are run 24x7 on a few NT4 servers at work. In order to keep the batch files running the boxes are logged into locally, batch files started, and the server is locked. I'd like to srvany the batch file to prevent the need to stay logged in locally but the issue is that we need to stop the script on occasions. If you have used srvany with batch files before you know that stopping the service only kills cmd.exe and leaves whatever processes the batch file started running. At this point we would have to either login locally to the box and kill the process or telnet in and kill it which pretty much kills the point of running it as a service.

My question is does anyone know of a way to run srvany with a batch file and have all child processes die when the service is stopped?

Thanks in advance.
 

Woodie

Platinum Member
Mar 27, 2001
2,747
0
0
I take it that running the .exe directly via srvany is not an option?

There are some options within the start command that might be able to make the .exe launch as a sub-process (or something like that) of the main VDM, so killing the batch job might kill the .exe.

Another option might be to run the script in PERL or REGINA or VBS, any of which may allow you to avoid using the vdm, which is probably the cause of your problem.
 

SoulAssassin

Diamond Member
Feb 1, 2001
6,135
2
0
Originally posted by: Woodie
I take it that running the .exe directly via srvany is not an option?

Unfortunately no, w/out going into everything, these processes have various database connections which tend to drop from time to time. The batch file has a loop in it to restart the process automatically. There's a $ impact if these are down for even a few minutes. Now if these were 2K boxes we could set it to restart if the service failed but that's not going to happen unfortunately.

Don't know a d@mn thing about PERL and have passing familiarity w VBS....will try to do some searches on it. I do vaguely remember reading something a while back regarding using start to run it as a child. Off to technet I go to check up on that...

Thanks and any other opinions are warmly welcomed.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,579
4,492
75
Not exactly, but I do know of a way to stop a running executable from a command line program. I'll dig up which one when I get home, but it's one of those task manager replacements for Win9x. I think it might work on Win2k...
 

SoulAssassin

Diamond Member
Feb 1, 2001
6,135
2
0
Originally posted by: Ken_g6
Not exactly, but I do know of a way to stop a running executable from a command line program. I'll dig up which one when I get home, but it's one of those task manager replacements for Win9x. I think it might work on Win2k...

You can do a kill from the cmd line, but you have to either telnet or locally login to the box which is what I'm trying to avoid. If there's a way to do it remotely (ie kill \\servername\program.exe) that would be sweet.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,579
4,492
75
I've never used an NT network, but couldn't you do something like \\servername\kill.exe program.exe? Or make a batchfile "killprog.bat" that does "kill program.exe" and run \\servername\killprog.bat?

Anyway, the program I was mentioning is prcview, if it helps.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
When you run things from a UNC path (i.e. \\server\blah\blah) they run locally on your machine, not the server.
 

bot2600

Platinum Member
May 18, 2001
2,075
0
76
Could you use Remote Command Service? It is an exe (RCMD.EXE) that comes on the NT 4 resource kit with srvany and lets you remotely run command line programs on the client, so I would think you could use it to run kill.exe to kill your exe.

Bot
 

Woodie

Platinum Member
Mar 27, 2001
2,747
0
0
Do NOT install rcmd. Although it will work, it's got security holes and is unsupported. If you want/need command-line access on the server, install the TELNET service.

SysInternals does code some handy stuff, so that may be the way to go.
 

SoulAssassin

Diamond Member
Feb 1, 2001
6,135
2
0
Yeah, I'm not a big fan of rcmd. Telnet would work, but it's a little too manual. Looks like the pskill will do what I need to do. I'm just going to write a script to do an xnet stop and then remotely kill the processes. I think there is a clean way to do it w VBS but in the interest of time I'm happy doing this.


Thanks guys!