Hi,
I have this vbscript which detects a CD-rom left inserted and then brings up an IE window with an animated.gif.
It works and has worked for a year now with IE 8 and IE 9, but now IE 10 and 11 is being rolled out, it just displays a blank window in IE 10 and IE 11, can anyone help modify it to make it work with all versions of Internet Explorer and display the gif within the IE?
Does something prevent gifs from appearing in IE 10 onwards?
Thanks,
RK
On Error Resume Next
dim oWMP, colCDROMs, i, strComputer, objWMIService, colItems, objItem
Const CDROM = 4
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
For Each objItem in colItems
If objItem.MediaLoaded <> 0 Then
Eject objItem.Drive
End If
Next
Sub Eject(Drive)
Set WshShell = CreateObject("WScript.Shell")
Set oWMP = Wscript.CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
if colCDROMs.Count >= 1 then
For i = 0 to colCDROMs.Count - 1
If oWMP.cdromCollection.item(index).driveSpecifier = Drive Then
colCDROMs.Item(i).Eject
Dim WindowTitle: WindowTitle = "CD left in"
Dim IE, vWid, vHt
sn = Wscript.ScriptName ' Script Name
fn = Wscript.ScriptFullName ' Fully Qualified Script Name
fp = Replace(fn, "\" & sn, "") ' Drive / Folder path
set WshShell = WScript.CreateObject("WScript.Shell")
Set IE = WScript.CreateObject("InternetExplorer.Application")
IE.FullScreen = 0
IE.MenuBar = 0
IE.ToolBar = 0
IE.StatusBar = 0
IE.addressbar = False
IE.Width = 970
IE.Height = 755
IE.Left = 0
IE.Top = 0
IE.Resizable = false
IE.Visible = true
IE.Navigate("about:blank")
do while ie.readystate<>4 : wscript.sleep 100 : loop
WshShell.AppActivate "Internet Explorer"
With IE.Document.ParentWindow
vWid= .Screen.AvailWidth: vHt= .Screen.AvailHeight
End With
IE.Left = (vWid - IE.Width)/2
IE.Top = (vHt - IE.Height)/2
IE.Document.Write "<html>"
IE.Document.Write "<head>"
IE.Document.Write "<title>" & WindowTitle & "</title>"
IE.Document.Write "</head>"
IE.Document.Write "<body background='" & fp & "\Animation1.gif'> <p></div></body>"
IE.Document.Write "<body bgcolor='#000000' style='overflow: hidden;'>"
IE.Document.Write "<div align='center'><p><br><br><br><br><br><br><br><br><br><br><br><br><br"
IE.Document.Write "<p><h6><font color='#666666'></font></h6></div>"
IE.Document.Write "</html>"
Wscript.sleep(10000)
End If
On Error Resume Next
dim oWMP, colCDROMs, i, strComputer, objWMIService, colItems, objItem
Const CDROM = 4
strComputer = "."
colCDROMs.Item(i).Eject
Next
End If
oWMP.close
set colCDROMs = nothing
set oWMP = nothing
set i = nothing
End Sub
I have this vbscript which detects a CD-rom left inserted and then brings up an IE window with an animated.gif.
It works and has worked for a year now with IE 8 and IE 9, but now IE 10 and 11 is being rolled out, it just displays a blank window in IE 10 and IE 11, can anyone help modify it to make it work with all versions of Internet Explorer and display the gif within the IE?
Does something prevent gifs from appearing in IE 10 onwards?
Thanks,
RK
On Error Resume Next
dim oWMP, colCDROMs, i, strComputer, objWMIService, colItems, objItem
Const CDROM = 4
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
For Each objItem in colItems
If objItem.MediaLoaded <> 0 Then
Eject objItem.Drive
End If
Next
Sub Eject(Drive)
Set WshShell = CreateObject("WScript.Shell")
Set oWMP = Wscript.CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
if colCDROMs.Count >= 1 then
For i = 0 to colCDROMs.Count - 1
If oWMP.cdromCollection.item(index).driveSpecifier = Drive Then
colCDROMs.Item(i).Eject
Dim WindowTitle: WindowTitle = "CD left in"
Dim IE, vWid, vHt
sn = Wscript.ScriptName ' Script Name
fn = Wscript.ScriptFullName ' Fully Qualified Script Name
fp = Replace(fn, "\" & sn, "") ' Drive / Folder path
set WshShell = WScript.CreateObject("WScript.Shell")
Set IE = WScript.CreateObject("InternetExplorer.Application")
IE.FullScreen = 0
IE.MenuBar = 0
IE.ToolBar = 0
IE.StatusBar = 0
IE.addressbar = False
IE.Width = 970
IE.Height = 755
IE.Left = 0
IE.Top = 0
IE.Resizable = false
IE.Visible = true
IE.Navigate("about:blank")
do while ie.readystate<>4 : wscript.sleep 100 : loop
WshShell.AppActivate "Internet Explorer"
With IE.Document.ParentWindow
vWid= .Screen.AvailWidth: vHt= .Screen.AvailHeight
End With
IE.Left = (vWid - IE.Width)/2
IE.Top = (vHt - IE.Height)/2
IE.Document.Write "<html>"
IE.Document.Write "<head>"
IE.Document.Write "<title>" & WindowTitle & "</title>"
IE.Document.Write "</head>"
IE.Document.Write "<body background='" & fp & "\Animation1.gif'> <p></div></body>"
IE.Document.Write "<body bgcolor='#000000' style='overflow: hidden;'>"
IE.Document.Write "<div align='center'><p><br><br><br><br><br><br><br><br><br><br><br><br><br"
IE.Document.Write "<p><h6><font color='#666666'></font></h6></div>"
IE.Document.Write "</html>"
Wscript.sleep(10000)
End If
On Error Resume Next
dim oWMP, colCDROMs, i, strComputer, objWMIService, colItems, objItem
Const CDROM = 4
strComputer = "."
colCDROMs.Item(i).Eject
Next
End If
oWMP.close
set colCDROMs = nothing
set oWMP = nothing
set i = nothing
End Sub