Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7816345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:50:06+00:00 2026-06-02T05:50:06+00:00

I am trying to write javascript which should run cmd.exe with a specified command

  • 0

I am trying to write javascript which should run cmd.exe with a specified command line in it like this docs.google.com/file/d/0B7QHCoQDlEvKWUZSX3oxUDI2SDg/edit:

I prepare a code after reading shellexecute method on microsoft site:

var objShell = new ActiveXObject("Shell.Application");
        objShell.ShellExecute("cmd.exe", "C: cd C:\\pr main.exe blablafile.txt auto", "C:\\WINDOWS\\system32", "open", "1");

but it does not insert command line in cmd.exe.

Could anybody help me? Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:50:08+00:00Added an answer on June 2, 2026 at 5:50 am

    Maybe you don’t have this ActiveX-control installed (or registered) in your computer.

    WScript.Shell should be found in every Windows:

    var run=new ActiveXObject('WSCRIPT.Shell').Run("commands to run");
    

    If there are spaces in commands to run, you need to use double quotes.

    Edit

    The content below is mainly from MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/gg537745(v=vs.85).aspx

    iRetVal = Shell.ShellExecute(
      sFile,
      [ vArguments ],
      [ vDirectory ],
      [ vOperation ],
      [ vShow ]
    )
    

    Let’s take [vDirectory]. The documentation says: “The fully qualified path of the directory that contains the file specified by sFile. If this parameter is not specified, the current working directory is used.”

    This means that you have an invalid path for this argument (having .cmd.exe at the end of it). Also all examples for creating the ActiveX are like this:

    var objShell = new ActiveXObject("shell.application");
    

    Notice the lowercase in "shell.application".

    And May12, thank’s for asking this. I didn’t know about this ActiveX control before, it seems to be very useful to me.

    EDIT II

    But have you understood it? Your example works perfect in my app:

    objShell.ShellExecute("cmd.exe", "cd C: C:\\cd c:\\ext_file main.exe test.txt", "C:\\WINDOWS\\system32", "open", 1);
    

    With three exceptions:

    1) The one I mentioned early in this answer about the path

    2) Escaped \ used also in arguments.

    3) The last argument is type of number, not a string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple javascript(no jquery or any other framework) which should
I'm trying to get JavaScript to read/write to a PostgreSQL database. I found this
I have a script called notify_me.php which I run like so: script type=text/javascript> //Run
I am new to JavaScript, and trying to understand how i should write classes
I'm trying to create a WYSIWYG editor using a div, just like Google Docs
I'm trying to write some javascript which executed will search the html for all
I am trying to write a Javascript function which writes the text to (eventually)
Trying to write a javascript bookmarklet to jump from a front end link into
I'm trying to write a javascript function that adds some DOM nodes to the
I am trying to write a javascript function with an if statement that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.