pkerlin101 Posted December 14, 2012 Report post Posted December 14, 2012 I have a VB script that will so a notification with a countdown timer. The script runs perfectly when ran on XP/WIN7 machines locally. When I try and run the script from an advertisement in SCCM it errors out with a Windows Script Host Error: ActiveX component can't create object Code: 800A01AD. It only errors out on Windows XP machines. The script advertisement works as expected when ran on WIN7 computers. I have also ran the code on the XP machine from the Run command by putting the network location where the script is stored. The code errors out on line 44 char 3 "For Each IE In CreateObject("Shell.Application").windows" ' Script starts here nMinutes = 5 nSeconds = 0 sMessage = "<font color=red size=-1><b>Warning</b></font>" ' Open a chromeless window with message with HTABox("lightgrey", 175, 450, 400, 500) .document.title = "Notification" .msg.innerHTML = sMessage do until .done.value or (nMinutes + nSeconds < 1) .msg.innerHTML = sMessage & "<br>" & nMinutes & ":" & Right("0"&nSeconds, 2) _ & " remaining<br>" wsh.sleep 1000 ' milliseconds nSeconds = nSeconds - 1 if nSeconds < 0 then if nMinutes > 0 then nMinutes = nMinutes - 1 nSeconds = 59 end if end if loop .done.value = true .close end with 'wsh.echo "process goes here ..." ' script ends here Function HTABox(sBgColor, h, w, l, t) Dim IE, HTA, sCmd, nRnd randomize : nRnd = Int(1000000 * rnd) sCmd = "mshta.exe ""javascript:{new " _ & "ActiveXObject(""InternetExplorer.Application"")" _ & ".PutProperty('" & nRnd & "',window);" _ & "window.resizeTo(" & w & "," & h & ");" _ & "window.moveTo(" & l & "," & t & ")}""" Set WshShell = WScript.CreateObject("WScript.Shell") with CreateObject("WScript.Shell") .Run sCmd, 1, False do until .AppActivate("javascript:{new ") : WSH.sleep 10 : loop end with 'WSHShell For Each IE In CreateObject("Shell.Application").windows If IsObject(IE.GetProperty(nRnd)) Then set HTABox = IE.GetProperty(nRnd) IE.Quit HTABox.document.title = "HTABox" HTABox.document.write _ "<HTA:Application contextMenu=no border=thin " _ & "minimizebutton=no maximizebutton=no sysmenu=no />" _ & "<body scroll=no style='background-color:" _ & sBgColor & ";font:normal 10pt Arial;" _ & "border-Style:inset;border-Width:3px'" _ & "onbeforeunload='vbscript:if not done.value then " _ & "window.event.cancelBubble=true:" _ & "window.event.returnValue=false:" _ & "done.value=true:end if'>" _ & "<input type=hidden id=done value=false>" _ & "<center><span id=msg> </span><br>" _ & "<input type=button id=btn1 value=' OK ' "_ & "onclick=done.value=true><center></body>" HTABox.btn1.focus Exit Function End If Next MsgBox "HTA window not found." wsh.quit End Function Quote Share this post Link to post Share on other sites More sharing options...