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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
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:
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:
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. 🙂