Open program with Javascript - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Open program with Javascript

busakornbusakorn Posts: 20Member
[b][red]This message was edited by busakorn at 2003-10-10 0:15:49[/red][/b][hr]
Hello all,

I'd like to make the web page that checks if the users have installed one program such as Winzip, if so, open that program, if not suggest them to install and then stop page from loading.

I have no idea, if this can be done with Javascript. Could you give me a hint or anything? Thank you very much in advance.




Comments

  • lillulillu Posts: 308Member
    Javascript itself cannot make system calls but if you're running a Windows system, you can insert Windows Script Host in javascript. (WScript is the root object of the Windows Script Host object model.)

    function runWinZip() {
    var shell = new ActiveXObject("WScript.shell");
    shell.run("winzip.exe");
    }




    : [b][red]This message was edited by busakorn at 2003-10-10 0:15:49[/red][/b][hr]
    : Hello all,
    :
    : I'd like to make the web page that checks if the users have installed one program such as Winzip, if so, open that program, if not suggest them to install and then stop page from loading.
    :
    : I have no idea, if this can be done with Javascript. Could you give me a hint or anything? Thank you very much in advance.
    :
    :
    :
    :
    :

    [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)

  • busakornbusakorn Posts: 20Member
    Wow, thank you very much, I've never known JS could do such a thing.
    But the problem is it's not completely what I'd like it to be.
    Is there any way to check whether this program is installed?
    Because this script just try to execute the program not checking it.
    It might not be the good idea to let the users to click the button to see nothing, is that?
    And one more thing is that browser will show the confirm dialog to let the users choose or choose not to run the program and the default value is no. But I want to force the users to run that program without asking them to confirm, can I do that?

    Thank you very much for the last reply, and in advance of all coming, any suggestions would be very appreciated.

    : Javascript itself cannot make system calls but if you're running a Windows system, you can insert Windows Script Host in javascript. (WScript is the root object of the Windows Script Host object model.)
    :
    : function runWinZip() {
    : var shell = new ActiveXObject("WScript.shell");
    : shell.run("winzip.exe");
    : }
    :
    :
    :
    :
    : : [b][red]This message was edited by busakorn at 2003-10-10 0:15:49[/red][/b][hr]
    : : Hello all,
    : :
    : : I'd like to make the web page that checks if the users have installed one program such as Winzip, if so, open that program, if not suggest them to install and then stop page from loading.
    : :
    : : I have no idea, if this can be done with Javascript. Could you give me a hint or anything? Thank you very much in advance.
    : :
    : :
    : :
    : :
    : :
    :
    : [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)
    :
    :

  • lillulillu Posts: 308Member
    Here's a simple check:

    [code]
    function runWinZip() {
    var shell = new ActiveXObject("WScript.shell");
    if (shell)
    { shell.run("winzip.exe"); }
    else
    { alert("WinZip is not installed on your system."); }
    }
    [/code]

    As I told you it's not JS that is doing this, but by using JS's syntax, we're working with the methods and properties of WScript which is the root object of the Windows Script Host object model. Therefore only Windows systems will be able to make use of your function.

    I'm sure there's a way of getting rid of the confirm dialog, but again this is there for security reasons. Even is you tinker with your own browser's security settings or even the browser's registry settings, (eg. I once managed to automate printing without showing the print dialog) but there's no way to overwrite the user's preferences. So they will or will not have the dialog depending on their security settings.

    : Wow, thank you very much, I've never known JS could do such a thing.
    : But the problem is it's not completely what I'd like it to be.
    : Is there any way to check whether this program is installed?
    : Because this script just try to execute the program not checking it.
    : It might not be the good idea to let the users to click the button to see nothing, is that?
    : And one more thing is that browser will show the confirm dialog to let the users choose or choose not to run the program and the default value is no. But I want to force the users to run that program without asking them to confirm, can I do that?
    :
    : Thank you very much for the last reply, and in advance of all coming, any suggestions would be very appreciated.
    :
    : : Javascript itself cannot make system calls but if you're running a Windows system, you can insert Windows Script Host in javascript. (WScript is the root object of the Windows Script Host object model.)
    : :
    : : function runWinZip() {
    : : var shell = new ActiveXObject("WScript.shell");
    : : shell.run("winzip.exe");
    : : }
    : :
    : :
    : :
    : :
    : : : [b][red]This message was edited by busakorn at 2003-10-10 0:15:49[/red][/b][hr]
    : : : Hello all,
    : : :
    : : : I'd like to make the web page that checks if the users have installed one program such as Winzip, if so, open that program, if not suggest them to install and then stop page from loading.
    : : :
    : : : I have no idea, if this can be done with Javascript. Could you give me a hint or anything? Thank you very much in advance.
    : : :
    : : :
    : : :
    : : :
    : : :
    : :
    : : [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)
    : :
    : :
    :
    :

    [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)

  • busakornbusakorn Posts: 20Member
    Thank you very much.
    I think I can now move on from this very point.

    Have a good day for you :-D

    : Here's a simple check:
    :
    : [code]
    : function runWinZip() {
    : var shell = new ActiveXObject("WScript.shell");
    : if (shell)
    : { shell.run("winzip.exe"); }
    : else
    : { alert("WinZip is not installed on your system."); }
    : }
    : [/code]
    :
    : As I told you it's not JS that is doing this, but by using JS's syntax, we're working with the methods and properties of WScript which is the root object of the Windows Script Host object model. Therefore only Windows systems will be able to make use of your function.
    :
    : I'm sure there's a way of getting rid of the confirm dialog, but again this is there for security reasons. Even is you tinker with your own browser's security settings or even the browser's registry settings, (eg. I once managed to automate printing without showing the print dialog) but there's no way to overwrite the user's preferences. So they will or will not have the dialog depending on their security settings.
    :
    : : Wow, thank you very much, I've never known JS could do such a thing.
    : : But the problem is it's not completely what I'd like it to be.
    : : Is there any way to check whether this program is installed?
    : : Because this script just try to execute the program not checking it.
    : : It might not be the good idea to let the users to click the button to see nothing, is that?
    : : And one more thing is that browser will show the confirm dialog to let the users choose or choose not to run the program and the default value is no. But I want to force the users to run that program without asking them to confirm, can I do that?
    : :
    : : Thank you very much for the last reply, and in advance of all coming, any suggestions would be very appreciated.
    : :
    : : : Javascript itself cannot make system calls but if you're running a Windows system, you can insert Windows Script Host in javascript. (WScript is the root object of the Windows Script Host object model.)
    : : :
    : : : function runWinZip() {
    : : : var shell = new ActiveXObject("WScript.shell");
    : : : shell.run("winzip.exe");
    : : : }
    : : :
    : : :
    : : :
    : : :
    : : : : [b][red]This message was edited by busakorn at 2003-10-10 0:15:49[/red][/b][hr]
    : : : : Hello all,
    : : : :
    : : : : I'd like to make the web page that checks if the users have installed one program such as Winzip, if so, open that program, if not suggest them to install and then stop page from loading.
    : : : :
    : : : : I have no idea, if this can be done with Javascript. Could you give me a hint or anything? Thank you very much in advance.
    : : : :
    : : : :
    : : : :
    : : : :
    : : : :
    : : :
    : : : [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)
    : : :
    : : :
    : :
    : :
    :
    : [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)
    :
    :

  • kbteokbteo Posts: 2Member
    If I am using WindowCE.net 4.1, and I open the CE Internet Explorer. and I have copy a exe file on the pocket pc.

    Will this script still working under Pocket PC or window ce environment ?

    thank you.

  • lillulillu Posts: 308Member
    I'm not sure about this particular OS (Windows CE) but for others like Win95/98 or WinNT4.0 WSH is installed if you install IE 5+, or if you download WSH from Microsoft (free).

    On Windows 2000 and Windows 98 Me WSH is installed by default.

    : If I am using WindowCE.net 4.1, and I open the CE Internet Explorer. and I have copy a exe file on the pocket pc.
    :
    : Will this script still working under Pocket PC or window ce environment ?
    :
    : thank you.
    :
    :

    [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)

  • kbteokbteo Posts: 2Member
    If that's say I am using window xp, i want to open certain part of file, maybe under directory D:xxprogrminstart.exe

    so how to write that code ? thank you.
    for WindowCE.net version, anyone have any solution ?


    : I'm not sure about this particular OS (Windows CE) but for others like Win95/98 or WinNT4.0 WSH is installed if you install IE 5+, or if you download WSH from Microsoft (free).
    :
    : On Windows 2000 and Windows 98 Me WSH is installed by default.
    :
    : : If I am using WindowCE.net 4.1, and I open the CE Internet Explorer. and I have copy a exe file on the pocket pc.
    : :
    : : Will this script still working under Pocket PC or window ce environment ?
    : :
    : : thank you.
    : :
    : :
    :
    : [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)
    :
    :

Sign In or Register to comment.