Use VBS script to “kill” a process on a remote server

You can use this VBS script to kill a running process on your local machine or a remote one. As a performance tester, I have found this useful since it allows me to kill the Mercury Agent Process (magentproc.exe) on remote LoadRunner generators.

Save the text below as a file called “ProcessKill.vbs” and run it to kill the agent process on your own machine.  You just need to change the strProcessKill and strComputer strings to determine the process that you want to kill and the machine where you want to kill it. By default the script runs on the local machine “.”

Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = “.”
strProcessKill = “‘magentproc.exe'”

Set objWMIService = GetObject(“winmgmts:” _& “{impersonationLevel=impersonate}!” & strComputer & “rootcimv2”)

Set colProcess = objWMIService.ExecQuery _(“Select * from Win32_Process Where Name = ” & strProcessKill )

For Each objProcess in colProcess
WSCript.Echo “Just killed process ” & strProcessKill _& ” on ” & strComputer

DOS FIND and FINDSTR commands

Here are a few uses for the DOS FIND and FINDSTR commands which can be useful in the preparation of test data files. Since FIND and FINDSTR are included in all Windows versions, they can be used on most test PCs without having to install PERL or GREP.

To quickly count the number of lines in a text file e.g. FILENAME.TXT you can use this command.
find /c /v “” FILENAME.TXT

To output all the lines containing a the word “error” in a text file e.g. FILENAME.TXT use this command. (If you add /i after the /v it will ignore the case of the search term.
find /v “error” FILENAME.TXT

A new file called ERRORS.TXT containing only the lines with the word “error” can be created by piping the output to a new file.
find /v “error” FILENAME.TXT > ERRORS.TXT

The DOS FINDSTR command can be used to find a string within a text file. For example after running performance tests you may have output files containing lines of bad data and you might want to delete the bad data from the original test data to get a clean run in subsequent tests.

In the example below, the account numbers which create errors have been written to a text file called ERROR_ACCOUNTS.TXT they can be found in the original file using the following command.

A new file containing only the “good data” can be created by piping the output to a new file.

FINDSTR is very powerful and a full reference guide can be found by typing FINDSTR /? at the command line. This includes the ability to use regular expressions in the command syntax.

Identify a web server

If ever you are asked to do a testing proof of concept and you need to quickly identify a web server type you can use idserve from Gibson Research Corporation. This sends a simple HTTP request to a webserver and presents the HTTP response headers to the user. This allows you to identify the server type which can be useful when working out the best way to write scripts to test the site.

The latest version also identifies non-HTTP server types (e.g. FTP, SMTP, POP or NEWS) and does reverse DNS lookups so that it can identify a server’s name if all you know is the IP address.

This can be downloaded from Steve Gibson’s website, along with a whole load of other utilities.

IdServe screenshotIf