1

I have a webpage that needs to run a program by ActiveX with some parameters.
I get those parameters with the following bit of JavaScript:

var var1 = getUrlParameter("par1", false);
var var2 = getUrlParameter("par2", false);
var var3 = getUrlParameter("par3", true);
var var4 = getUrlParameter("par4", true);

I'm creating a new ActiveX Object:

MyObject = new ActiveXObject("WScript.Shell")  

Then I need to run a command, I've tried several options with double and single quotes but nothing works. Sometimes the program isn't started at all, sometimes the variables aren't getting through. I've tried:

MyObject.Run(""C:\\Path with\\some spaces\\program.exe" D:\\pathtoafile /PARAM:/para1="+var1+"\,/para2="+var2+"\,/para3="+var3+"\,/para4=\""+var4+"\"");
MyObject.Run('"C:\\Path with\\some spaces\\program.exe" D:\\pathtoafile /PARAM:/para1="+var1+"\,/para2="+var2+"\,/para3="+var3+"\,/para4=\""+var4+"\"');
MyObject.Run("'C:\\Path with\\some spaces\\program.exe' D:\\pathtoafile /PARAM:/para1="+var1+"\,/para2="+var2+"\,/para3="+var3+"\,/para4=\""+var4+"\"");
3
  • I think you should rename your variables as I suspect they are not valid names. Try maybe p1, p2, p3, p4 instead for example. Also if this is being run from a webpage I would expect that the WScript.Shell ActiveX object is blocked as an un-safe object. Otherwise a malicious website could run any command on your system. Commented Dec 29, 2014 at 10:44
  • In addition what AeroX has said: ActiveXes work in IE only if allowed (I wouldn't allow any web-page to run ActiveXes though). Commented Dec 29, 2014 at 10:52
  • ActiveX is allowed. I test it with "alert" that's how i can see when the vars are passed through. Commented Dec 29, 2014 at 11:00

1 Answer 1

1

After some more hours of trying if found it!

MyObject.Run('"C:\\Path with\\some spaces\\program.exe"' + " " + "D:\\pathtoafile" + " " +  "/PARAM:/para1="+var1+"\,/para2="+var2+"\,/para3="+var3+"\,/para4=\""+var4+"\"");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.