Results 1 to 4 of 4

Thread: Starting and stopping Apps with a script

  1. #1
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001

    Starting and stopping Apps with a script

    I'm puzzled with this problem:
    I downloaded and installed a nice spam filter, called "email express!"

    It seems to meet my needs, but I need a way to start and stop it when I start
    and stop my dial up connection. If I leave the filter running when I'm off line, it
    becomes unresponsive the next time I check the mail.

    I copied and pasted and modified some VBScript code from the net:

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run("%windir%\RUNDLL32.EXE RNAUI.DLL,RnaDial Internet")
    ReturnCode = WshShell.Run("%windir%\RUNDLL32.EXE RNAUI.DLL,RnaDial Internet", 1, True)
    So far, this script will start the connection, and the filter, but I've been unable to
    discover a way to shut down the processes from a VBScript.
    Am I barking up the wrong tree? My system is win98, and I also have perl on
    the system, but don't know any perl either.
    I came in to the world with nothing. I still have most of it.

  2. #2
    Senior Member
    Join Date
    Jan 2003
    The unix kill command has been ported to Win32..... you could use some *nix commands together.... ps x | grep <app name>, kill <yada>..... something along those lines.. I'll include a zip with the files... you can play around with them...

    I have also added the cut command, so you can cut the process id from the line you grep from the ps command... if you need assistance setting up the exact commands just let me know... I'm just too lazy to think that hard atm without prompting.

    OK I got bored..... so here's some commands for ya..

    ps x | grep <process name> | cut -f 2 will return the process number
    and you can kill process number so then at the end I suppose you could just add | kill dunno if it accepts stdin tho... but i'm sure you can figure it out..

    IT Blog: .:Computer Defense:.
    PnCHd (Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".

  3. #3
    Senior Member
    Join Date
    Nov 2001
    or you could download pstools from systernals.com run 'pslist -t' to get a tree view of processes running and in your script shell out to 'pskill processesname'
    Bukhari:V3B48N826 “The Prophet said, ‘Isn’t the witness of a woman equal to half of that of a man?’ The women said, ‘Yes.’ He said, ‘This is because of the deficiency of a woman’s mind.’”

  4. #4
    Junior Member
    Join Date
    Jul 2003

    Post Using Scripting Tools

    The other replies will work, but they don't quite answer your question if I understand you correctly. My answer is going to be more OS specific than theirs but it--to me--is a better solution.

    With the release of Windows 2000 Microsoft made some great strides into the 'power user' area that eluded them for so long. Both of the other posters are all to aware of this as their solutions are all we could do in the pre-win2k world. Naming turn to a 3rd party or support pak .exe and shell to it.

    Then comes Win2k and some great technoligies. Like improved WSH, WMI, ADSI, and several new ones for Exchange. The one you are interested in for this feat is called WMI. A very powerful object indeed! Below you will find the script you need to stop a process. Microsoft has some great white papers on this and the other technologies I've mentioned. It is a relief to finally have some power in the native OS and not have to monkey around with 3rd party stuff and add ons. Because you never know if they will be on a system or not! This script should work on any Win2k system and I don't know maybe some older stuff if it has enough SDKs loaded!

    Set proc1 = GetObject("WinMgmts://COMPUTERNAME/root/cimv2")
    Set Qry1 = Proc1.ExecQuery("SELECT * FROM win32_process")
    For each Item in Qry1
    If Item.Caption = "calc.exe" then
    End If

    A few things will need to be changed. First off obviously the giant COMPUTERNAME needs to be replaced with the actual computer name you are running the script against. (Notice I say against as WMI works wonderfully across the network on other systems) Also the "calc.exe" is just for demonstration, you will change that to the name of the process you are killing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts