Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows - Running a system command from within HTML 1

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
IL
HI,

I work locally on a Windowa machine,no servers !
I display a big HTML log ,that includes 2 frames of JS.
After 2 frames are build,I want to run a Windows system command (unzip some file to some destination),so that my links from HTML will work (unzipped files will be targets for my links).

How do I get JS to run the above system command?
Thanks

Long live king Moshiach !
 
To run local system commands you have to have local privledges. Look into HTA (HTML for Applications).
HTA is essentially HTML with Javascript or VBScript and it executes with local account privledges. If the .hta file is run directly from your PC it works normally, if you execute it from a web server then it will give an ActiveX warning message and require permission before executing.
This of course will only work with Internet Explorer.



At my age I still learn something new every day, but I forget two others.
 
Here is some sample code showing two ways to execute a command. One method uses a click event, one uses an HREF.
One is calling an exe file, one calls a batch file.

Code:
<html>
<head>
<script type="text/javascript">
function runApp(which) {
  WshShell = new ActiveXObject("WScript.Shell");
  WshShell.Run (which,1,true);
}
</script>
</head>
<body>
<!-- Two ways to create a link to run the app. -->
<font onClick="runApp('file://c:/winnt/notepad.exe');" style="cursor: hand;"><u>Notepad</u></font>
<br>
<!-- Or use <a> descriptor -->
<a href="runApp('file://c:/test.bat');">Batch File</a>
</body>
</html>

At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top