Resources | ASP | Shell in ASP

Run a Shell Through ASP:


Several people have e-mailed me after having problems getting this script to run. If you're having trouble, check out this thread in our message boards.

The Windows Environment has a very powerful object, the Shell, which allows you to remotely run programs as if you were calling them from the Command Line (the DOS prompt). All of Microsoft's programming languages allow you to access this object. The following is an example of how to do it in ASP. If you choose to have a function like this on your page, though, be warned: You must set strict access control on this page. Otherwise, you are leaving your server open to attack from malicious users.

The following routine takes two parameters: progName (the Command Line program you would like to call), and strVariable (a string, representing anything you want to pass into the call of the command line).

For example, if I wanted to PING "AnySite.com", I would make a call in my ASP page like this: CommandLine "ping","127.0.0.1".

The routine then takes the result and puts it into a .txt file. Try using the script to run nslookup, ping, tracert, etc.


Related Links: Resolve Host Names in ASP | Get IP Addresses in ASP


Want to discuss this article, or other development issues? Visit our message boards!

Or contact us directly with a comment or question on this article: click here !
armbrustconsulting.com