swipe
Posts: 146
Score: 2 Joined: 2/17/2006 Status: offline
|
I was going to PM this but it was too big for a PM so I'll paste here instead. Anyone, please feel free to correct any bad/inefficient coding. For most normal programs that just require a reboot I'll use miniNotify but for stuff that needs lots of informational stuff I use this method: Firstly, paste this code into notepad and save as XP_SP3_Popup.hta or whatever else you want to call it. Then all you do is create another program under your SP3 SMS package (which I assume you have already done, if you haven't create a Package and a program for your SP3 exe ) and call the XP_SP3_Popup.hta file. Under the Environment tab, set it to run with admin rights but allow the "user to interact with the program" and also set to run "whether user is logged on or not." You then need to go to your Service pack 3 program properties (which I assume you alreday have) and in the Advanced tab under "Run another program first" choose the SP3 package and the XP_SP3_Popup.hta program you just created. I always tick it to run this everytime too. Then advertise the SP3 program which then call the hta program first when it runs. Here is the code. I've tried to comment the sections the best I can: <html> <HEAD> <TITLE>SP3 Upgrade</TITLE> <HTA:APPLICATION ID="oMyApp" APPLICATIONNAME="SP3 Upgrade" BORDER="3" CAPTION="yes" SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" WINDOWSTATE="maximize"> <!--Script to resize window--> <script language="javascript" type="text/javascript"> function RestoreWindowSize() { window.resizeTo(1024, 670); } </script> <!--CSS to set the text to red for the countdown timer (see right down below for "function countdown"--> <style> #countdown { position: relative; top: +12px; color: red;} </style> <!--VBscript to check if user is logged in. If user is logged in explorer.exe process will be running. If not the message window will quit (by killing the mshta.exe popup window process) and will move on and run the next SMS program in the chain--> <script LANGUAGE="VBScript"> Set objWMI = GetObject("winmgmts:") Set colProcessList = objWMI.ExecQuery ("Select * from Win32_Process Where Name = 'explorer.exe'") If colProcessList.Count = 0 Then Kill_hta_popup Else End if Function Kill_hta_popup Set oWMI = CreateObject("wBEMScripting.sWBEMLocator") Set oServer = oWMI.ConnectServer Set ProcessSet = oServer.InstancesOf("Win32_Process") For Each oProcess in ProcessSet If oProcess.Name = "mshta.exe" then oProcess.Terminate End if Next End Function </script> </HEAD> <body bgcolor="white" onload="RestoreWindowSize();" > <!--Here I call my company logo image file. If you are not using a logo remove this part --> <p> <img src="companylogo.gif" > </p> <!-- Seperate lines and paragraphs for text and font/style/colour for the message window --> <p><align="center"><font color="black" size="5" face="Arial"> <strong> Windows XP Service Pack 3 is about to install on this PC. This may take up to 90 minutes to complete depending on the age of the computer. Please save your work now before closing this window.</strong> </align></font> </p> <br> <p><align="center"><font size="5" face="Arial"> <strong> To begin the installation, you may close this message window now otherwise it will count down from 30 minutes and then the installation will commence. The computer will automatically restart (without warning) once the installation is complete and then you may log back on.</strong> </align></font> </p> <br> <p><align="center"><font color="red" size="5" face="Arial"> <strong> Under no circumstances should you attempt to shut down this computer until the process is complete or you risk rendering it in an unusable state. Please do not work on the PC while the update is installing. </align></font> </p> <br> <p><align="center"><font size="5" face="Arial"> <strong> Time remaining (min:secs) until XP SP3 installation: </strong><div id="countdown"></div> <div id="notifier"></div></p> </align></font> <!-- Javascript code for countdown timer. Please note the time is set in seconds, unlike the close window timer for the popup window which is in milliseconds--> <script type="text/javascript"> function display( notifier, str ) { document.getElementById(notifier).innerHTML = str; } function toMinuteAndSecond( x ) { return Math.floor(x/60) + ":" + x%60; } function setTimer( remain, actions ) { (function countdown() { display("countdown", toMinuteAndSecond(remain)); actions[remain] && actions[remain](); (remain -= 1) >= 0 && setTimeout(arguments.callee, 1000); })(); } // Change this setTimer value to set timer. Currently set to 30minutes setTimer(1800, { // Optional things below (commented out) that you can add //10: function () { display("notifier", "Just 10 seconds to go"); }, //5: function () { display("notifier", "5 seconds left"); }, // 1: function () { display("notifier", "Installation will now begin"); } }); </script> </strong><br> <!-- This code will close the window after the time set (in miliseconds). Currently set to 30minutes to match the countdown above. Change this value to increase or decrease timeout. Make sure it mnatches the timeout sepcified in the JS timeout above.--> <script> setTimeout("self.close();",18000000) </script> <!--Code to insert close window button on the window--> <BUTTON onclick= 'window.close()'>Close Window</BUTTON> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </body> </html> Now, you asked about another popup to display while the XP Service Pack is running. Well, SMS won't run any other programs while it is currently running a program so I use a little trick. Let me know if you want to know how to do that. It involves using SMSinstaller to create an exe file that spawns a hta popup and then quits the exe but leaves the popup on the screen, allowing SMS to move on a run the next program. I also call another SP3 completed hta popup that is set to run on logon after the final reboot to let the users know it has finished. I hope this helps. As always, test, test and test before deploying to a production environment. Swipe
|