Background:
This is a script to -
- Install multiple apps
- Checks for the existing processes if any application need to be close before executing the application. if the process exits then will product a pop-up. The popup will be closed in desired duration then the application will be closed
- Installs all the applications
- Provides installation complete popup MSG window for user and it will auto close in desired duration
********************************************************************
'********************************************************************
' Software upgrade script with a MSG box
' Venu Singireddy for Venu Singireddy's Blog
'*********************************************************************
On error resume next
Option Explicit
Dim objFSO
Dim fso
Dim objfile
Dim Wshell
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Set Wshell = CreateObject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim sScriptPath: sScriptPath = Mid(WScript.ScriptFullName, 1, Len(WScript.ScriptFullName) - Len(WScript.ScriptName))
' loop the check
Do while ProcessIsRunning("Notepad.exe")
' Warning MSG to user
Wshell.Popup "The software Installer has detected that Notepad is running." & vbCrLf & vbCrLf & _
"In order to install Some Software software, Notepad need to be closed" & vbCrLf &_
"Please close your Notepad then click OK." & vbCrLf & vbCrLf & _
"Otherwise in 10 minutes, the software installer will close your Notepad automatically and will continue with the software installation." & vbCrLf & vbCrLf & _
"The upgrade will take approximately 2 minutes." & vbCrLf & vbCrLf & _
"Please keep Notepad closed until you are notfied this process is complete. ", 600, "Venu SIngireddy blog"
Dim oShell : Set oShell = CreateObject("WScript.Shell")
'Kill notepad
oShell.Run "taskkill /F /IM Notepad.exe", , True
Wscript.Sleep 30000
Loop
Function ProcessIsRunning(sProcessName)
Dim objWMIService, objProcess, colProcess
Dim sList
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process")
For Each objProcess in colProcess
If LCase(objProcess.Name) = LCase(sProcessName) Then
ProcessIsRunning = True
End If
Next
End Function
'Install required software
WShell.Run Chr(34) & sScriptPath & "some_exe.exe" & Chr(34) & " /q ",0,True
WShell.Run Chr(34) & sScriptPath & "some_exe.exe" & Chr(34) & " /q ",0,True
WshShell.Run "some_msi.msi /qb", 0, True
WshShell.Run "some_msi.msi /qb", 0, True
'Complete MSG to end user and will disapper in x seconds
Wshell.Popup "Some Software software installation Completed", 600, "Venu Singireddy Blog"
WScript.Quit()
*****************************************************************************
This is a script to -
- Install multiple apps
- Checks for the existing processes if any application need to be close before executing the application. if the process exits then will product a pop-up. The popup will be closed in desired duration then the application will be closed
- Installs all the applications
- Provides installation complete popup MSG window for user and it will auto close in desired duration
********************************************************************
'********************************************************************
' Software upgrade script with a MSG box
' Venu Singireddy for Venu Singireddy's Blog
'*********************************************************************
On error resume next
Option Explicit
Dim objFSO
Dim fso
Dim objfile
Dim Wshell
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Set Wshell = CreateObject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim sScriptPath: sScriptPath = Mid(WScript.ScriptFullName, 1, Len(WScript.ScriptFullName) - Len(WScript.ScriptName))
' loop the check
Do while ProcessIsRunning("Notepad.exe")
' Warning MSG to user
Wshell.Popup "The software Installer has detected that Notepad is running." & vbCrLf & vbCrLf & _
"In order to install Some Software software, Notepad need to be closed" & vbCrLf &_
"Please close your Notepad then click OK." & vbCrLf & vbCrLf & _
"Otherwise in 10 minutes, the software installer will close your Notepad automatically and will continue with the software installation." & vbCrLf & vbCrLf & _
"The upgrade will take approximately 2 minutes." & vbCrLf & vbCrLf & _
"Please keep Notepad closed until you are notfied this process is complete. ", 600, "Venu SIngireddy blog"
Dim oShell : Set oShell = CreateObject("WScript.Shell")
'Kill notepad
oShell.Run "taskkill /F /IM Notepad.exe", , True
Wscript.Sleep 30000
Loop
Function ProcessIsRunning(sProcessName)
Dim objWMIService, objProcess, colProcess
Dim sList
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process")
For Each objProcess in colProcess
If LCase(objProcess.Name) = LCase(sProcessName) Then
ProcessIsRunning = True
End If
Next
End Function
'Install required software
WShell.Run Chr(34) & sScriptPath & "some_exe.exe" & Chr(34) & " /q ",0,True
WShell.Run Chr(34) & sScriptPath & "some_exe.exe" & Chr(34) & " /q ",0,True
WshShell.Run "some_msi.msi /qb", 0, True
WshShell.Run "some_msi.msi /qb", 0, True
'Complete MSG to end user and will disapper in x seconds
Wshell.Popup "Some Software software installation Completed", 600, "Venu Singireddy Blog"
WScript.Quit()
*****************************************************************************
No comments:
Post a Comment