February 2012
M T W T F S S
« Jan   Mar »
 12345
6789101112
13141516171819
20212223242526
272829  
153

Refs

Categories

Archives

profile for slm on Stack Exchange, a network of free, community-driven Q&A sites

Delicious Bookmarks for February 9th from 11:05 to 17:57

These are my links for February 9th from 11:05 to 17:57:

[one-liner]: Running a Windows Program from a HTML Page in Internet Explorer

Background

We recently needed a way to launch executables on a Windows system, but wanted to run them from a web browser, locally. Turns out to be pretty easy with a little bit of VBScript.

Solution

Here’s a quick example on how to make a .html file that can be used to launch applications locally. This seems like a total hack and might have nefarious uses but it also can be used constructively. It only appears to work with Internet Explorer on Windows, and you’ll need to tell IE to allow the script to work, but other than that it’s an easy workaround.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<html>
<body>
<SCRIPT language=VBScript>
  sub RunProg(CommandLine)
    Dim ObjShell
    Set ObjShell = CreateObject("WScript.Shell")
    errorstate = ObjShell.Run(CommandLine, 1, False)
    'Destroy Command line object
    Set ObjShell = Nothing
  end sub
</SCRIPT>
<INPUT onclick="RunProg('C:\Windows\system32\calc.exe')" type='button'
value='pushme'>
</body>
</html>

The key to this trick is calling this VBScript from within an HTML script block.

1
2
3
4
5
6
7
  sub RunProg(CommandLine)
    Dim ObjShell
    Set ObjShell = CreateObject("WScript.Shell")
    errorstate = ObjShell.Run(CommandLine, 1, False)
    'Destroy Command line object
    Set ObjShell = Nothing
  end sub
References

NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.

Delicious Bookmarks for February 8th through February 9th

These are my links for February 8th through February 9th: