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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code works in Internet Explorer 8 and 9, but not in 10 or 11

Status
Not open for further replies.

rkelly58

Technical User
Feb 25, 2014
6
GB
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
 
You might want to check Tools > Internet Options > Advanced > Security > "Allow active content to run in files on my computer".
 
Hi, tried that, makes no difference.
Any other suggestions?
 
Managed to get it kind of working using

With IE.Document.ParentWindow.screen
vWid= .AvailWidth
vHt= .AvailHeight
End With

Problem is the IE window is not the same dimension as the image. GIF is 952 x 714, how do I make the IE window auto adjust to the centre of the screen to display the GIF correctly. At the moment the gif is almight tiled when displayed on different resolutons. What can I do to ensure the IE window is in the centre of the screen and adjusts the GIF to fit?



 
Hi [peace]
Try this HTA

Code:
<HTML>
<head>
<HTA:APPLICATION
APPLICATIONNAME="Open CD"
BORDER="THIN"
BORDERSTYLE="NORMAL"
ICON= "Magnify.exe"
INNERBORDER="NO"
MAXIMIZEBUTTON="NO"
MINIMIZEBUTTON="NO"
SCROLL="NO"
SELECTION="NO"
SINGLEINSTANCE="YES"/>
<style>
    body{
        background-color: lightblue;
    }
    label,.btn{
        font-weight: bold;
    }
</style>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<title>Open CD</title>
<SCRIPT LANGUAGE="VBScript">
'************************************************************************************
Sub window_onload()
	CenterWindow 280,270
End Sub
'************************************************************************************
Sub CenterWindow(x,y)
	Dim iLeft,itop
	window.resizeTo x,y
	iLeft = window.screen.availWidth/2 - x/2
	itop = window.screen.availHeight/2 - y/2
	window.moveTo ileft,itop
End Sub
'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/OpenCD()_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
sub OpenCD()
On Error Resume Next
Dim ts
Dim strDriveLetter
Dim intDriveLetter
Dim fs
Const CDROM = 4
Set fs = CreateObject("Scripting.FileSystemObject")
' Detection des lecteurs de CD
strDriveLetter = ""
For intDriveLetter = Asc("A") To Asc("Z") 'Limitez aux lecteurs souhaitأ©s
	Err.Clear
	If fs.GetDrive(Chr(intDriveLetter)).DriveType = CDROM Then
		If Err.Number = 0 Then
			strDriveLetter = Chr(intDriveLetter)
        Exit For
		End If
	End If
Next
' Ouvrir tous les lecteurs
Set owmp = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = owmp.cdromCollection
For d = 0 To colCDROMs.Count - 1
	colCDROMs.Item(d).Eject
Next
Set owmp = Nothing
Set colCDROMs = Nothing
end sub
 </SCRIPT>
</HEAD>
<BODY>
<center><a href="#" onClick="Call OpenCD()"><img src="[URL unfurl="true"]http://3.bp.blogspot.com/-c0ZQaaOHXv0/T_fHiFP0RkI/AAAAAAAAAEs/fjkAtPkUaV4/s200/CD-ROM-icon.png"></a></center>[/URL]
</BODY>
</HTML>
 
Thanks for posting, but has to be in vbscript.

Just need to know how I go about centering the gif file in IE so that it works on all screen solutions. At the moment I get repeat if the resolution is higher
 
Just wanted to add this works kind of ok n a Single Screen.
The problem mainly occurs when you have dual monitors with a stretched screen, it must be taking the calculations based on both screens combined.

IS there a way just to take the reolution of the main screen on the left?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top