Tuesday, October 19, 2004

AutoPlay Internet Explorer

Today I wanted to create a CD that automatically opens Internet Explorer with a certain HTML page. It seems this simple act is not so simple. The best reference I found was MSJ from 1999.

The solution below works on Win2000 and WinXP. Notice that Norton Antivirus asks the user to permit the script to run.

File: Autorun.inf
[autorun]
OPEN=Wscript autorun.js

File: Autorun.js
// Create an instance of the scripting Shell Object
WshShell = WScript.CreateObject("WScript.Shell");

// Have the Shell Object call ShellExecute on our HTML
// file
WshShell.Run('iexplore "' + WshShell.CurrentDirectory + '\index.html"', 3, 0);

// Destroy the Shell Object
WScript.DisconnectObject(WshShell);

1 Comments:

At 5:59 AM, Blogger Acid Zebra said...

I had the same problem once; dunno if yours is solved now.
On a IBM mouse driver CD I found this batch file that was called from autorun. The advantage is that it will autodetect your CD drive letter and open a page on that CD. the HTML files it open uses an activeX control to lauch programs without that pesky "opening files form the internet can be unsafa" bla bla warning. If you're interested drop me a line.

Here's the batch code:

@echo off

rem author gail a wingfield
rem installer batch program version 1.0
rem searches for customer CDROM drive
rem and opens the page in internet explorer

ver > c:\ver.txt
start /w regsvr32.exe /s launch.ocx

rem test for win95

find /c /i "windows 95" c:\ver.txt

if errorlevel 1 goto win98
goto win9x

:win98
rem test for win98

find /c /i "windows 98" c:\ver.txt

if errorlevel 1 goto winnt
goto win9x

:winnt
rem test for nt

find /c /i "windows nt version 4.0" c:\ver.txt

if errorlevel 1 goto winme
goto win9x

:winme
rem test for me

find /c /i "windows millennium" c:\ver.txt

if errorlevel 1 goto win2k
goto win9x


:win2k
rem launch for windows 2000
start iexplore.exe %cd%launch.htm
goto end


:win9x
rem launch for window 9x
cd > c:\dir.txt
find /c /i "d:\" c:\dir.txt
if errorlevel 1 goto 2
goto d

:2
find /c /i "e:\" c:\dir.txt
if errorlevel 1 goto 3
goto e

:3
find /c /i "f:\" c:\dir.txt
if errorlevel 1 goto 4
goto f

:4
find /c /i "g:\" c:\dir.txt
if errorlevel 1 goto 5
goto g

:5
find /c /i "h:\" c:\dir.txt
if errorlevel 1 goto 6
goto h

:6
find /c /i "i:\" c:\dir.txt
if errorlevel 1 goto 7
goto i

:7
find /c /i "j:\" c:\dir.txt
if errorlevel 1 goto 8
goto j

:8
find /c /i "k:\" c:\dir.txt
if errorlevel 1 goto 9
goto k

:9
find /c /i "l:\" c:\dir.txt
if errorlevel 1 goto 10
goto l

:10
find /c /i "m:\" c:\dir.txt
if errorlevel 1 goto 11
goto m

:11
find /c /i "n:\" c:\dir.txt
if errorlevel 1 goto 12
goto n

:12
find /c /i "o:\" c:\dir.txt
if errorlevel 1 goto 13
goto o

:13
find /c /i "p:\" c:\dir.txt
if errorlevel 1 goto 14
goto p

:14
find /c /i "q:\" c:\dir.txt
if errorlevel 1 goto 15
goto q

:15
find /c /i "r:\" c:\dir.txt
if errorlevel 1 goto 16
goto r

:16
find /c /i "s:\" c:\dir.txt
if errorlevel 1 goto 17
goto s

:17
find /c /i "t:\" c:\dir.txt
if errorlevel 1 goto 18
goto t

:18
find /c /i "u:\" c:\dir.txt
if errorlevel 1 goto 19
goto u

:19
find /c /i "v:\" c:\dir.txt
if errorlevel 1 goto 20
goto v

:20
find /c /i "w:\" c:\dir.txt
if errorlevel 1 goto 21
goto w

:21
find /c /i "x:\" c:\dir.txt
if errorlevel 1 goto 22
goto x

:22
find /c /i "y:\" c:\dir.txt
if errorlevel 1 goto 23
goto y

:23
find /c /i "z:\" c:\dir.txt
if errorlevel 1 goto end
goto z

:d
start iexplore.exe d:\launch.htm
goto del

:e
start iexplore.exe e:\launch.htm
goto del

:f
start iexplore.exe f:\launch.htm
goto del

:g
start iexplore.exe g:\launch.htm
goto del

:h
start iexplore.exe h:\launch.htm
goto del

:i
start iexplore.exe i:\launch.htm
goto del

:j
start iexplore.exe j:\launch.htm
goto del

:k
start iexplore.exe k:\launch.htm
goto del

:l
start iexplore.exe l:\launch.htm
goto del

:m
start iexplore.exe m:\launch.htm
goto del

:n
start iexplore.exe n:\launch.htm
goto del

:o
start iexplore.exe o:\launch.htm
goto del

:p
start iexplore.exe p:\launch.htm
goto del

:q
start iexplore.exe q:\launch.htm
goto del

:r
start iexplore.exe r:\launch.htm
goto del

:s
start iexplore.exe s:\launch.htm
goto del

:t
start iexplore.exe t:\launch.htm
goto del

:u
start iexplore.exe u:\launch.htm
goto del

:v
start iexplore.exe v:\launch.htm
goto del

:w
start iexplore.exe w:\launch.htm
goto del

:x
start iexplore.exe x:\launch.htm
goto del


:y
start iexplore.exe y:\launch.htm
goto del

:z
start iexplore.exe z:\launch.htm
goto del

:del
if exist c:\ver.txt del c:\ver.txt
if exist c:\dir.txt del c:\dir.txt
goto end

:end

 

Post a Comment

<< Home