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

  • Home
  • SEARCH
  • 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 6200971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:28:01+00:00 2026-05-24T04:28:01+00:00

I want to have Javascript run say cmd.exe if there is already not one

  • 0

I want to have Javascript run say cmd.exe if there is already not one running.

I was hoping there is a way to have javascript look at running processes and then if the name is in the list dont run. but if it’s not run the process.

  • 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-05-24T04:28:02+00:00Added an answer on May 24, 2026 at 4:28 am

    Javascript is not the best route for scripting OS-level process control. If javascript were able to have such direct access to your operating system, it would be an extreme security risk to ever browse the internet.

    Internet Explorer does have a mechanism to script Windows from javascript, but you would have to adjust your security settings to allow this to occur. Other browsers do not even offer the possibility.

    This code will execute notepad.exe in Internet Explorer, after choosing to “Allow blocked content” from the security warning:

    var shell = new ActiveXObject('WScript.Shell');
    shell .Run("notepad.exe");
    

    docs: http://msdn.microsoft.com/en-us/library/aew9yb99%28v=vs.85%29.aspx

    So, we can use this method to both list active processes and to start one if it is appropriate:

    function startUniqueProcess(process_name, process_path) {
        // create a shell object and exec handle
        var shell = new ActiveXObject('WScript.Shell');
        var handle = shell.Exec("tasklist.exe");
    
        // loop through the output of tasklist.exe
        while (!handle.StdOut.AtEndOfStream) {
            // grab a line of text
            var p = handle.StdOut.ReadLine();
            // split on space
            p = p.split(' ');
            // check for split lines longer than 2
            if (p.length < 2)
                continue;
            // match process_name to this item
            if (p[0] == process_name) {
                // clean up and return false, process already running
                shell = null;
                handle = null;
                return false;
            } // end :: if matching process name
        } // end :: while
    
        // clean up
        handle = null;
    
        // process not found, start it
        return shell.Exec(process_path);
    }
    
    
    // example use
    var result = startUniqueProcess('notepad.exe', 'notepad.exe');
    if (result === false)
        alert('did not start, already open');
    else
        alert('should be open');
    

    Keep in mind, this is proof of a concept – in practice I would not suggest you ever, ever, ever do this. It is browser-specific, dangerous, exploitable, and generally bad practice. Web languages are for web applications, javascript is not intended to be a OS scripting language despite what Microsoft might want to tell you. 🙂

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

Sidebar

Related Questions

I have some jQuery/JavaScript code that I want to run only when there is
I want to run javascript/Python/Ruby inside my application. I have an application that creates
I have an ASP.NET checkbox, and I want to run some javascript before it
Fairly basic question i'm hoping. In the following javascript, I want to run the
I want to write some javascript and have it call into the DOM for
I have a neat little javascript data grid and I want people to be
I have a form element that I want to address via javascript, but it
I have a long snippet of HTML I want some javascript variable to equal
I want to call a c# function from my javascript function. I have a
I apologize if this is a duplicate. Let's say I have a JavaScript function

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.