fmpfmpf Posted November 29, 2010 Share Posted November 29, 2010 <html><head><script type="text/javascript" language="JavaScript">function LaunchCommand(){var launcher = new ActiveXObject("WScript.Shell");launcher.Run("file://C:/ColorCop.exe");window.open('','_self','');window.close();}</script></head><body><br><br><br><br><br><center><font size = 5>Click button to open file</font><br><br><input name="Command" value="Click me"onclick="LaunchCommand()" type="button"><body><center></html>The above attached is my .html code to open a .exe file in C:However, i wish to have both the .html and .exe file in the same folder. When i shift these 2 files to another location, the .html file will still link to the .exe file and still open it when clicked.How can i make this possible?TQ Link to comment Share on other sites More sharing options...
thescientist Posted November 29, 2010 Share Posted November 29, 2010 then don't have it reference the C: drive. if they are both in the same folder, then all you probably need is this: launcher.Run("file://ColorCop.exe"); Link to comment Share on other sites More sharing options...
fmpfmpf Posted November 29, 2010 Author Share Posted November 29, 2010 then don't have it reference the C: drive. if they are both in the same folder, then all you probably need is this: launcher.Run("file://ColorCop.exe"); i did try that, but it doesnt work.i click on the button, but nothing happens. Link to comment Share on other sites More sharing options...
thescientist Posted November 29, 2010 Share Posted November 29, 2010 try launcher.Run("file:\\ColorCop.exe"); unfortunately I'm not too familiar with the ActiveX object Link to comment Share on other sites More sharing options...
ShadowMage Posted November 29, 2010 Share Posted November 29, 2010 Maybe remove the file:// prefix as in: launcher.Run("ColorCop.exe"); I don't know ActiveX either, but I know that's the way you reference files in the same folder with PHP/(X)HTML/CSS Link to comment Share on other sites More sharing options...
fmpfmpf Posted November 29, 2010 Author Share Posted November 29, 2010 Maybe remove the file:// prefix as in:launcher.Run("ColorCop.exe"); I don't know ActiveX either, but I know that's the way you reference files in the same folder with PHP/(X)HTML/CSS SUPER!!! It works!!TQ Link to comment Share on other sites More sharing options...
fmpfmpf Posted November 30, 2010 Author Share Posted November 30, 2010 SUPER!!! It works!!TQ I just found out that it wasnt working as wanted.Using launcher.Run("ColorCop.exe"); will link to the ColorCop.exe in the desktop, and not the ColorCop.exe in the same folder.Any solutions?TQ Link to comment Share on other sites More sharing options...
justsomeguy Posted November 30, 2010 Share Posted November 30, 2010 That means the working directory for the shell is the user's desktop instead of the folder the HTML file is in. Look for a way to change the working directory in the shell to the same directory as the HTML file. I'm not sure how to use Javascript to get the path of the current file, but there might be a shell command you can use with the ActiveX object. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.