Anthony
Wed Sep 22 10:29:06 CDT 2004
Torgeir Bakken (MVP) wrote:
> Anthony wrote:
>
>> Could you explin how to impletment these in a script?
>>
>> as an example:
>>
>> if HollyJollyChristmas = "The best time of the year" then
>> objshell.run ("\\<server ip>\<file name> /q:a /r:n",1,True
>> end if
>>
>> So if I wanted to show that their was progress during the install of
>> <file name> how would I inject this into the IE progress bars code?
>>
>> TIA
>
>
> Below is a modified version of the 3rd example by Joe Earnest in
> this link:
>
http://groups.google.com/groups?selm=%23BDv%24av%24DHA.1288%40TK2MSFTNGP10.phx.gbl
>
>
>
> '--------------------8<----------------------
> HollyJollyChristmas = "The best time of the year"
>
> if HollyJollyChristmas = "The best time of the year" then
>
> sTitle= "Installing updates"
>
> nScrW= createobject( _
> "htmlfile").parentWindow.screen.availWidth
> nScrHt= createobject( _
> "htmlfile").parentWindow.screen.availHeight
>
> showBar oIe, sTitle
> wscript.sleep 50
>
> oIe.document.parentWindow.document.script.listop "<br />"
>
> sInsert = "Installing security update KB123456, please wait...<br />"
> oIe.document.parentWindow.document.script.listop sInsert
> 'objshell.run "\\<server ip>\<file name> /q:a /r:n",1,True
> wscript.sleep 2000 'demo dummy operation only
> sInsert = "Finished installing security update KB123456<br />"
> oIe.document.parentWindow.document.script.listop sInsert
>
> sInsert = "Installing security update KB65432, please wait...<br />"
> oIe.document.parentWindow.document.script.listop sInsert
> ' objshell.run "\\<server ip>\<file name 2> /q:a /r:n",1,True
> wscript.sleep 2000 'demo dummy operation only
> sInsert = "Finished installing security update KB65432<br />"
> oIe.document.parentWindow.document.script.listop sInsert
>
> wscript.sleep 1000
> msgbox "Script is complete.", _
> vbOkOnly +vbSystemModal, sTitle
> on error resume Next
> oIe.quit
> on error goto 0
>
> end if
>
>
> function showBar (roIe, usTitle)
>
> set roIe= createobject( _
> "internetExplorer.application")
>
> roIe.navigate("about:blank")
>
> do
> wscript.sleep 50
> loop until roIe.readyState=4
>
> with roIe
> .fullScreen= true
> .toolbar = false
> .statusBar = false
> .addressBar = false
> .resizable= false
> .width= 540
> .height= 240
> .left= (nScrW -520) \2
> .top= (nScrHt -240) \2
>
> with .document
> .writeLn ("<!doctype html public>")
> .writeLn ("<html style=""border-style:outset;" _
> & "border-width:4px"" " _
> & "onKeyDown=""vbscript:SuppressKeys"" " _
> & "onHelp=""vbscript:SuppressIeFns"" " _
> & "onContextMenu=""vbscript:SuppressIeFns"">")
> .writeLn ("<head>")
> .writeLn ("<title>" & usTitle & "</title>")
> .writeLn ("<style type=""text/css"">")
> .writeLn ("body {background-color:#ece9d8;" _
> & "text-align:center;" _
> & "vertical-align:middle}")
> .writeLn ("</style>")
> .writeLn ("<script language=""vbscript"">")
> .writeLn ("function SuppressKeys ()")
> .writeLn ("select case window.event.keyCode")
> .writeLn ("case 112, 114, 116")
> .writeLn ("case else: if NOT " _
> & "cbool(window.event.ctrlKey) then " _
> & "exit function")
> .writeLn ("end select")
> .writeLn ("window.event.keyCode= 0")
> .writeLn ("window.event.cancelBubble= true")
> .writeLn ("window.event.returnValue= false")
> .writeLn ("end function")
> .writeLn ("function SuppressIeFns ()")
> .writeLn ("window.event.cancelBubble= true")
> .writeLn ("window.event.returnValue= false")
> .writeLn ("end function")
> .writeLn ("function ListOp (usInsert)")
> .writeln ("window.insertfile.insertAdjacentHtml " _
> & """beforeBegin"", usInsert")
> .writeln ("window.insertfile.scrollIntoView")
> .writeLn ("end function")
> .writeLn ("</script>")
> .writeLn ("</head>")
> .writeLn ("<body scroll=""no"">")
> .writeLn ("<table>")
> .writeLn ("<tr>")
> .writeLn ("<td style=""text-align:center;" _
> & "font-family:Arial;font-size:16pt;" _
> & "font-weight:bold"">")
> .writeLn ("Installing updates")
> .writeLn ("</td>")
> .writeLn ("</tr>")
> .writeLn ("<tr>")
> .writeLn ("</td>")
> .writeLn ("</tr>")
> .writeLn ("<tr>")
> .writeLn ("<td style=""padding-top:15px"">")
> .writeLn ("<div id=""progresslist"" " _
> & "style=""height:150px;width:460px;" _
> & "max-height:100%;max-width:100%;" _
> & "padding-left:10px;text-align:left;" _
> & "font-family:Arial;font-size:10pt;" _
> & "font-weight:bold;border-style:inset;" _
> & "border-width:thin;overflow:scroll"">")
> .writeLn ("<span id=""insertfile""></span>")
> .writeLn ("</div>")
> .writeLn ("</td>")
> .writeLn ("</tr>")
> .writeLn ("<tr>")
> .writeLn ("<td style=""padding-top:20px;" _
> & "width:400px;font-family:Arial;" _
> & "font-size:10pt;" _
> & "font-weight:bold"">")
> .writeLn ("</td>")
> .writeLn ("</tr>")
> .writeLn ("</table>")
> .writeLn ("</body>")
> .writeLn ("</html>")
> end with
>
> .visible= true
> end with
>
> wscript.sleep 100
> createobject("wscript.shell").appActivate _
> usTitle
> 'createobject("autoItX.control").winActivate _
> ' usTitle, ""
>
> end function
>
> '--------------------8<----------------------
>
I hope I am not the only one that is not getting this...
Let me paste actual code with ip's changed to protect the innocent.
Hopefully you can see what I am doing worng, as it seems to just go in
an endless loop.
In particular I have changed the patch for Visual Studio .NET 2002 to
try and use the progress bar.
'********************************************************************************
'*********************************************************************************
'9.15.04
'Script to install MS04-027 and MS04-028 released on 9.14.04
'028 (833987) Link:
http://www.microsoft.com/technet/security/bulletin/ms04-028.mspx
'027 (884933) Link:
http://www.microsoft.com/technet/security/bulletin/ms04-027.mspx
'
'*********************************************************************************
'*********************************************************************************
Dim objShell, SMSClient
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colSysEnvVariables = objShell.Environment("Process")
'*********************************************************************************
'See if SMS client is installed, if client is detected exit.
'*********************************************************************************
'On Error Resume Next
'SMSClient = objShell.RegRead("HKLM\SOFTWARE\Microsoft\SMS\Client\Client
Components\SMS Client Base Components\Installation properties\installed
version")
' If SMSClient = "9.99.9999.9999" Then
' objShell.Popup "You are an SMS client and will receive the updates
from SMS. Click OK to exit.", vbOKOnly, "SMS Client"
' Wscript.quit
' end If
'********************************************************************************
'********************************************************************************
'Get the OS version and IE version.
'********************************************************************************
OSVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\CurrentVersion")'get OS version from registry assign
the value to OSVersion
IEVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Internet
Explorer\Version") 'get IE version from the registry assign the value to
IEVersion
On Error Resume Next
'********************************************************************************
'Function to see if registry key exists
'********************************************************************************
Function RegKeyExists(ByVal sRegKey) ' Returns True or False based on
the existence of a registry key.
Dim sDescription, oShell
Set oShell = CreateObject("WScript.Shell")
RegKeyExists = True
sRegKey = Trim (sRegKey)
If Not Right(sRegKey, 1) = "\" Then
sRegKey = sRegKey & "\"
End If
On Error Resume Next
oShell.RegRead "HKEYNotAKey\"
sDescription = Replace(Err.Description, "HKEYNotAKey\", "")
Err.Clear
oShell.RegRead sRegKey
RegKeyExists = sDescription <> Replace(Err.Description, sRegKey, "")
On Error Goto 0
End Function
'********************************************************************************
'function to show progress bar
'********************************************************************************
Function showBar (roIe, usTitle)
Set roIe= createobject("internetExplorer.application")
roIe.navigate("about:blank")
Do
WScript.sleep 50
loop Until roIe.readyState=4
with roIe
.fullScreen= True
.toolbar = False
.statusBar = False
.addressBar = False
.resizable= False
.width= 540
.height= 240
.left= (nScrW -520) \2
.top= (nScrHt -240) \2
with .document
.writeLn ("<!doctype html public>")
.writeLn ("<html style=""border-style:outset;" _
& "border-width:4px"" " _
& "onKeyDown=""vbscript:SuppressKeys"" " _
& "onHelp=""vbscript:SuppressIeFns"" " _
& "onContextMenu=""vbscript:SuppressIeFns"">")
.writeLn ("<head>")
.writeLn ("<title>" & usTitle & "</title>")
.writeLn ("<style type=""text/css"">")
.writeLn ("body {background-color:#ece9d8;" _
& "text-align:center;" _
& "vertical-align:middle}")
.writeLn ("</style>")
.writeLn ("<script language=""vbscript"">")
.writeLn ("function SuppressKeys ()")
.writeLn ("select case window.event.keyCode")
.writeLn ("case 112, 114, 116")
.writeLn ("case else: if NOT " _
& "cbool(window.event.ctrlKey) then " _
& "exit function")
.writeLn ("end select")
.writeLn ("window.event.keyCode= 0")
.writeLn ("window.event.cancelBubble= true")
.writeLn ("window.event.returnValue= false")
.writeLn ("end function")
.writeLn ("function SuppressIeFns ()")
.writeLn ("window.event.cancelBubble= true")
.writeLn ("window.event.returnValue= false")
.writeLn ("end function")
.writeLn ("function ListOp (usInsert)")
.writeln ("window.insertfile.insertAdjacentHtml " _
& """beforeBegin"", usInsert")
.writeln ("window.insertfile.scrollIntoView")
.writeLn ("end function")
.writeLn ("</script>")
.writeLn ("</head>")
.writeLn ("<body scroll=""no"">")
.writeLn ("<table>")
.writeLn ("<tr>")
.writeLn ("<td style=""text-align:center;" _
& "font-family:Arial;font-size:16pt;" _
& "font-weight:bold"">")
.writeLn ("Installing updates")
.writeLn ("</td>")
.writeLn ("</tr>")
.writeLn ("<tr>")
.writeLn ("</td>")
.writeLn ("</tr>")
.writeLn ("<tr>")
.writeLn ("<td style=""padding-top:15px"">")
.writeLn ("<div id=""progresslist"" " _
& "style=""height:150px;width:460px;" _
& "max-height:100%;max-width:100%;" _
& "padding-left:10px;text-align:left;" _
& "font-family:Arial;font-size:10pt;" _
& "font-weight:bold;border-style:inset;" _
& "border-width:thin;overflow:scroll"">")
.writeLn ("<span id=""insertfile""></span>")
.writeLn ("</div>")
.writeLn ("</td>")
.writeLn ("</tr>")
.writeLn ("<tr>")
.writeLn ("<td style=""padding-top:20px;" _
& "width:400px;font-family:Arial;" _
& "font-size:10pt;" _
& "font-weight:bold"">")
.writeLn ("</td>")
.writeLn ("</tr>")
.writeLn ("</table>")
.writeLn ("</body>")
.writeLn ("</html>")
end With
.visible= True
end With
wscript.sleep 100
CreateObject("wscript.shell").appActivate usTitle
'createobject("autoItX.control").winActivate _
' usTitle, ""
end Function
'********************************************************************************
'Get Office Version
'********************************************************************************
Function GetOfficeVer()
sRegPre = "HKLM\SOFTWARE\Microsoft\Office\"
sRegPost = "\Common\InstallRoot\"
Select Case True
Case RegKeyExists(sRegPre & "11.0" & sRegPost) 'checks for Office 2003
sOfficeVer = "2003"
Case RegKeyExists(sRegPre & "10.0" & sRegPost) 'checks for Office XP
sOfficeVer = "2002"
Case RegKeyExists(sRegPre & "9.0" & sRegPost) 'checks for Office 2000
sOfficeVer = "2000"
Case RegKeyExists(sRegPre & "8.0" & sRegPost) 'checks for Office 97
sOfficeVer = "97"
Case Else
sOfficeVer = "0"
End Select
GetOfficeVer = sOfficeVer
End Function
OfficeVersion = GetOfficeVer
'********************************************************************************
'Get Visual Studio Version
'********************************************************************************
Function GetVisualStudioVer()
sRegPre = "HKLM\SOFTWARE\Microsoft\VisualStudio\"
If RegKeyExists(sregpre & "7.0") Then 'checks to see if Visual
Studio 2002 is installed.
VSVersion = 2002
End If
If RegKeyExists(sRegPre & "7.1") Then 'checks to see if Visual
Studio 2003 is installed.
VSVersion = VSVersion + 1
End If
If RegKeyExists(sRegPre & "7.0" And "7.1") Then 'checks to see if
both versions are installed
VSVersion = VSVersion + 1
End If
End Function
'********************************************************************************
'Get Visio Version
'********************************************************************************
Function GetVisioVersion()
sRegPre = "HLKM\SOFTWARE\Microsoft\Shared Tools\AddIn
Designer\Microsoft Visio\"
If RegKeyExists(sRegPre & "Microsoft Visio 10.0") Then
VisioVersion = 2002
End If
If RegKeyExists(sRegPre & "Microsoft Visio 11.0") Then
VisioVersion = VisionVersion + 1
End If
If RegKeyExists(sRegPre & "Microsoft Visio 10.0" & "Microsoft Visio
11.0") Then
VisioVersion = VisioVersion + 1
End If
End Function
'********************************************************************************
'Get Project Version
'********************************************************************************
Function GetProjectVersion()
sRegPre = "HLKM\SOFTWARE\Microsoft\Shared Tools\AddIn
Designer\Microsoft Project\"
If RegKeyExists(sRegPre & "Microsoft Project 10.0") Then
ProjectVersion = 2002
End If
If RegKeyExists(sRegPre & "Microsoft Project 11.0") Then
ProjectVersion = ProjectVersion + 1
End If
If RegKeyExists(sRegPre & "Microsoft Project 10.0" & "Microsoft
Project 11.0") Then
ProjectVersion = ProjectVersion + 1
End If
End Function
'********************************************************************************
'Patch for Office 2003 027/028
'********************************************************************************
'If OfficeVersion = 2003 Then
' objShell.Run "\\<server
ip>\hotfixes\2004\028\office2003-kb838905-client-enu.exe /Q:A
/R:N",1,True '028
' WScript.Echo "Office 2003 - 028"
' objShell.Run "\\<server
ip>\hotfixes\2004\027\Office2003\office2003-kb873378-fullfile-enu.exe
/Q:A /R:N",1,True '027
' WScript.Echo "Office 2003 - 027"
'End If
'********************************************************************************
'Patch for Office XP 027/028
'********************************************************************************
'If OfficeVersion = XP Then
' objShell.Run "msiexec /i \\<server ip>\OfficeXPSP3\PRO.MSI /qb
REINSTALL=All REINSTALLMODE=vomu",1,True
' WScript.Echo "027/028 Office XP"
'End If
'********************************************************************************
'Patch for Office 2000 027/028
'********************************************************************************
'If OfficeVersion = 2000 Then
' objShell.Run "msiexec /i \\<server ip>\Office\data1.MSI /qb
REINSTALL=All REINSTALLMODE=vomu",1,True
' WScript.Echo "027/028 Office 2000"
'End If
'********************************************************************************
'IE6 SP1 Patch
'********************************************************************************
'If OSVersion < 5.1 then
' if IEVersion = "6.00.2800" Then
' objShell.Run "\\<server
ip>\hotfixes\2004\028\IE6.0sp1-KB833989-x86-ENU.exe /Q:A /R;N",1,True
' WScript.Echo "028 IE6 SP1"
' End If
'End If
'********************************************************************************
'Server 2003 Patch 028
'********************************************************************************
'If OSVersion = 5.2 Then
' objShell.Run "\\<server
ip>\hotfixes\2004\028\WindowsServer2003-KB833987-x86-ENU.exe /quiet
/passive /norestart",1,True
' WScript.Echo "028 Server 2003"
'End If
'********************************************************************************
'Windows XP Patch 028
'********************************************************************************
'If OSVersion = 5.1 Then
' objShell.Run "\\<server
ip>\hotfixes\2004\028\WindowsXP-KB833987-x86-ENU.exe /quiet /passive
/noresart",1,True
' WScript.Echo "028 Windows XP"
'End If
'********************************************************************************
'Project 2002 SP1 : Patch 028
'********************************************************************************
If ProjectVersion = 2002 Or 2004 then
objShell.Run "\\<server
ip>\hotfixes\2004\028\Project2002-KB831931-FullFile-ENU.exe /Q:A
/R:N",1,True
WScript.Echo "Project 2002 SP1"
End if
'********************************************************************************
'Project 2003 : Patch 028
'********************************************************************************
If ProjectVersion = 2003 Or 2004 Then
objShell.Run "\\<server
ip>\hotfixes\2004\028\Project2003-KB838344-FullFile-ENU.exe /Q:A
/R:N",1,True
WScript.Echo "Project 2003"
End If
'********************************************************************************
'Visio 2002 SP2 : Patch 028
'********************************************************************************
If VisioVersion = 2002 Or 2004 Then
objShell.Run "\\<server
ip>\hotfixes\2004\028\Visio2002-KB831932-FullFile-ENU.exe /Q:A /R:N",1,True
WScript.Echo "Visio 2002"
End if
'********************************************************************************
'Visio 2003 : Patch 028
'********************************************************************************
If VisionVersion = 2003 Or 2004 Then
objShell.Run "\\<server
ip>\hotfixes\2004\028\Visio2003-KB838345-FullFile-ENU.exe /Q:A /R:N",1,True
WScript.Echo "Visio 2003"
End If
'********************************************************************************
'Visual Studio .NET 2002 : Patch 028
'********************************************************************************
'If VSVerison = 2002 or 2004 Then
' objShell.Run ("\\<server ip>\hotfixes\2004\028\VS7.0-KB830348-X86.exe
/q"),1,True
' WScript.Echo "VS.NET 2002"
'End If
If VSVerison = 2002 or 2004 Then
sTitle= "Installing Visual Studio 2002 updates"
nScrW= createobject("htmlfile").parentWindow.screen.availWidth
nScrHt= createobject("htmlfile").parentWindow.screen.availHeight
showBar oIe, sTitle
wscript.sleep 50
oIe.document.parentWindow.document.script.listop "<br />"
sInsert = "Installing security update KB123456, please wait...<br />"
oIe.document.parentWindow.document.script.listop sInsert
objShell.Run ("\\<server ip>\hotfixes\2004\028\VS7.0-KB830348-X86.exe
/q"),1,True
'wscript.sleep 2000 'demo dummy operation only
sInsert = "Finished installing security update KB123456<br />"
oIe.document.parentWindow.document.script.listop sInsert
' sInsert = "Installing security update KB65432, please wait...<br />"
' oIe.document.parentWindow.document.script.listop sInsert
' objshell.run "\\<server ip>\<file name 2> /q:a /r:n",1,True
' wscript.sleep 2000 'demo dummy operation only
' sInsert = "Finished installing security update KB65432<br />"
' oIe.document.parentWindow.document.script.listop sInsert
'wscript.sleep 1000
MsgBox "Script is complete.", _
vbOKOnly +vbSystemModal, sTitle
On error resume Next
oIe.quit
On error goto 0
End If
'********************************************************************************
'Visual Studio .NET 2003 : Patch 028
'********************************************************************************
If VSVersion = 2003 Or 2004 Then
objShell.Run ("\\<server ip>\hotfixes\2004\028\VS7.1-KB830348-X86.exe
/q"),1,True
WScript.Echo "VS.NET 2003"
End If
'********************************************************************************
'.NET Framework Version 1.0 SP2 : Patch 028
'********************************************************************************
'objShell.Run ("\\<server
ip>\hotfixes\2004\028\NDP1.0sp3-KB867461-X86-Enu.exe /q"),1,True
'WScript.Echo ".NET FRMWRK 1.0 SP2"
'v1.0.3705
'********************************************************************************
'.NET Framework Version 1.1 : Patch 028
'********************************************************************************
'objShell.Run ("\\<server
ip>\hotfixes\2004\028\NDP1.1sp1-KB867460-X86.exe /q"),1,True
'WScript.Echo ".NET FRMWRK 1.1"
'********************************************************************************
'Picture It! Digital Image Suite and Greetings Version 7.0 : Patch 028
'********************************************************************************
'objShell.Run ("\\<server ip>\hotfixes\2004\028\gdiplus_7.exe /Q:A
/R:N"),1,True
'WScript.Echo "Digital Image Suite 7"
'********************************************************************************
'Picture It! Digital Image Suite and Greetings 2002 : Patch 028
'********************************************************************************
'objShell.Run ("\\<server ip>\hotfixes\2004\028\gdiplus_6.exe /Q:A
/R:N"),1,True
'WScript.Echo "Digital Image Suite 2002"
'********************************************************************************
'Picture It! Digital Image Suite and Greetings Verison 9.0 : Patch 028
'********************************************************************************
'objShell.Run ("\\<server ip>\hotfixes\2004\028\gdiplus_9.exe /Q:A
/R:N"),1,True
'WScript.Echo "Digital Image Suite 9"
'********************************************************************************
'Producer for MSFT Office PowerPoint All Versions : Patch 028
'********************************************************************************
'objShell.Run ("\\<server ip>\hotfixes\2004\028\msprod2.exe /Q:A
/R:N"),1,True
'WScript.Echo "Producer for PowerPoint"
'********************************************************************************
'Error handling
'********************************************************************************
If Err <> 0 Then
objShell.Popup "The update did not complete successfully. Please
contact Help Desk at 3033." & VbCrLf & "Error code " & Err.Number & " -
" & Err.Description, 0, "Patch Install Was Not Successful", vbOKOnly +
vbExclamation
Err.Clear
End If
WScript.quit
'********************************************************************************
'Popup for completion of script and verifypatch.bat install
'********************************************************************************
If Err = 0 Then
objshell.Run "regedit /s \\<server ip>\VerifyPatch\VerifyPatch.reg"
objFSO.copyfile "\\<server ip>\VerifyPatch\verifypatch.bat.lnk",
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\"), True
WScript.Echo "copied To " &
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\")
objFSo.copyfile "\\<server ip>\VerifyPatch\verifypatch.bat",
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\"), True
objFSO.copyfile "\\<server ip>\VerifyPatch\sleep.exe",
objShell.ExpandEnvironmentStrings("%SYSTEMROOT%\"), True
objShell.Popup "The update completed successfully." & VbCrLf & VbCrLf &
"Please reboot your system to complete the installation and launch the
patch verify.",0, "Patch Installation Completed", vbOKOnly + vbExclamation
Err.Clear
End If