Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







Script: Execute a DOS Program

Posted by on Monday, January 19, 2004 (PST)

Script: Demonstrates how to execute a shell command from WSH. Uses the WScript.Shell Object and the Run Method.

 

 
/**
 *         Name: DOSCommand.js
 *  Description: Demonstrates how to execute a DOS Shell
 *               and Launch a program with parameters.
 *       Author: Daren Thiel
 *         Date: 31 Dec 1998
 *          Web:
http://www.winscripter.com
 **/
/* Create WSH Shell */
oShell = WScript.CreateObject( "WScript.Shell" );
/* Launch a command shell "/K" <- keeps it open  */
/* list the files in the windows directory using */
/* dir c:\windows                                */
oShell.Run( "command.com /K dir c:\\windows" );
/* Launch word pad with a file to open passed   */
/* as a command line parameter                  */
oShell.Run( "wordpad.exe c:\\autoexec.bat" );
/* Let the user know that we are done           */
WScript.Echo( "Done" );
 

Comments:

dos script
By drmorton on Friday, June 06, 2008 (PST)

I used your script to execute a dos program from a web application and I get a message, "Device not ready" and the program never runs.

 

Any Ideas?

 

 

DOS CRITICAL PROGRAM
By drmorton on Monday, June 16, 2008 (PST)

Hey Dan,

 

I need a script that will open a mission critical legacy dos program via a web site.

 

The program runs great on the server side, but the client side just does nothing.

 

Can you HELP ME!????

 

Thank you, Pepper Morton



WSH and ADSI Administrative Scripting

New Articles
  • List installed COM objects and associated ProgIDs
    Script: Lists all COM Objects and their associated ProgIDs (If available). Win32_ClassicCOMClassSetting

  • Script: File Rotator
    Script: Rotate files where the most current file has the lowest number in the archive. When files exceed the retention period, they are deleted. Typically used for log files, backups, etc..

  • Script: Create IIS Website and DNS record
    Script: Dan Casier sent me this script that will create a website and appropriate DNS record. The script is intended for Windows 2000 Server with local DNS and necessary DNS mof installed.


  • Winscripter   |  WSH   |  Forums   |  Downloads   |  Books   |  Links   |  Amazon