run dos command from html page


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: run dos command from html page

Hybrid View

  1. #1
    steve hamilton Guest

    run dos command from html page


    what does the /c DIR represent in the code below
    i know what the %comspec% is but not the rest
    what i need to do is run a python file from an HTML page
    for a demonstration for collage

    Run a DOS Command From an HTML Page
    This is achieved by using the Windows Script Host. First, create an instance
    of the object WScript.Shell. Then, use its Run method to execute the DOS
    command. For example, say your HTML page has a button that will run the DIR
    command when clicked. The onclick jscript function would look something like
    this:
    -------------------------
    function btnDIR_onclick()
    {
    var WshShell = new ActiveXObject("WScript.Shell");
    WshShell.Run("%comspec% /c DIR");
    WshShell.Quit;
    }
    ----------------------------
    The %comspec% string in the argument for Run() specifies the path and file
    name of the command interpreter, Cmd.exe.



  2. #2
    Dan Guest

    Re: run dos command from html page

    Is just the /c (command) switch for the command.com (default value for
    %comspec%) or DOS shell translator, /c allows to run a command with the
    translator without opening a new shell session, sorta like you'd in
    Unix/Linux, you specify the shell to use for the commands, so you can run C
    shell commands in a Bash session and so on.


    Dan

    "steve hamilton" <stevehamilton@blueyonder.co.uk> wrote in message
    news:3cc03656$1@10.1.10.29...
    >
    > what does the /c DIR represent in the code below
    > i know what the %comspec% is but not the rest
    > what i need to do is run a python file from an HTML page
    > for a demonstration for collage
    >
    > Run a DOS Command From an HTML Page
    > This is achieved by using the Windows Script Host. First, create an

    instance
    > of the object WScript.Shell. Then, use its Run method to execute the DOS
    > command. For example, say your HTML page has a button that will run the

    DIR
    > command when clicked. The onclick jscript function would look something

    like
    > this:
    > -------------------------
    > function btnDIR_onclick()
    > {
    > var WshShell = new ActiveXObject("WScript.Shell");
    > WshShell.Run("%comspec% /c DIR");
    > WshShell.Quit;
    > }
    > ----------------------------
    > The %comspec% string in the argument for Run() specifies the path and file
    > name of the command interpreter, Cmd.exe.
    >
    >




  3. #3
    ynwt Guest

    Re: run dos command from html page


    Steve,
    /c for "carries out the command specified by the string and then terminates"

    you might want to know more command line parameter for cmd.exe
    simply go to the command prompt and then type "cmd /?".

    have fun
    ynwt
    ====
    "steve hamilton" <stevehamilton@blueyonder.co.uk> wrote:
    >
    >what does the /c DIR represent in the code below
    >i know what the %comspec% is but not the rest
    >what i need to do is run a python file from an HTML page
    >for a demonstration for collage
    >
    >Run a DOS Command From an HTML Page
    >This is achieved by using the Windows Script Host. First, create an instance
    >of the object WScript.Shell. Then, use its Run method to execute the DOS
    >command. For example, say your HTML page has a button that will run the

    DIR
    >command when clicked. The onclick jscript function would look something

    like
    >this:
    >-------------------------
    >function btnDIR_onclick()
    >{
    > var WshShell = new ActiveXObject("WScript.Shell");
    > WshShell.Run("%comspec% /c DIR");
    > WshShell.Quit;
    >}
    >----------------------------
    >The %comspec% string in the argument for Run() specifies the path and file
    >name of the command interpreter, Cmd.exe.
    >
    >



  4. #4
    Ryan Nichols Guest

    Re: run dos command from html page


    "steve hamilton" <stevehamilton@blueyonder.co.uk> wrote:
    >
    >what does the /c DIR represent in the code below
    >i know what the %comspec% is but not the rest
    >what i need to do is run a python file from an HTML page
    >for a demonstration for collage
    >
    >Run a DOS Command From an HTML Page
    >This is achieved by using the Windows Script Host. First, create an instance
    >of the object WScript.Shell. Then, use its Run method to execute the DOS
    >command. For example, say your HTML page has a button that will run the

    DIR
    >command when clicked. The onclick jscript function would look something

    like
    >this:
    >-------------------------
    >function btnDIR_onclick()
    >{
    > var WshShell = new ActiveXObject("WScript.Shell");
    > WshShell.Run("%comspec% /c DIR");
    > WshShell.Quit;
    >}
    >----------------------------
    >The %comspec% string in the argument for Run() specifies the path and file
    >name of the command interpreter, Cmd.exe.
    >


    The /c is a switch for the cmd.exe program. It tells cmd to run the command
    then close. DIR is of course the DOS command to list contents of a directory.
    If you go to start:run then type in 'cmd.exe /c DIR' thats the basic equivalent
    of what is happening above. Leave the /c off and you'll see the window does
    not close. For your application, Im sure something like "%comspec% c:\paethon\nameofpaethonprogram"
    would do it? I have no idea how to run paethon from a command line...and
    Im no expert

    Ryan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center