We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Need a batch file

Medium Priority
317 Views
Last Modified: 2012-05-11
Hi there,

I am running a program silently to deploy it to 50 users via SMS. I need a batch file or VBS script that will run this command

Setup.exe /S /v/qn

and then a message saying.

Please note that your computer is in the process of receiving Adapt PT 2010and it will prompt you to reboot shortly. This is part of an overall update for all the engineers who have Adapt PT8.  For any questions with regard to this update please contact the service  and assign a ticket.

Thanks,
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Hi, does this VBScript do the job?

Rob.
Set objShell = CreateObject("WScript.Shell")
objShell.Run "Setup.exe /S /v/qn", 1, False
MsgBox "Please note that your computer is in the process of receiving Adapt PT 2010and it will prompt you to reboot shortly. This is part of an overall update for all the engineers who have Adapt PT8.  For any questions with regard to this update please contact the service  and assign a ticket."

Open in new window

Commented:
Here you go
Option Explicit
On Error Resume Next

Const WAIT_FOR_PROGRAM_TO_TERMINATE = True
' Window Type: 0 = Hide, 1 = Activate and Display
Const WINDOW_TYPE = 0

Dim objWSH               : Set objWSH = CreateObject("WScript.Shell")
Dim strScriptPath        : strScriptPath = objWSH.CurrentDirectory
Dim strRunCommand        : strRunCommand = strScriptPath & "\" & "Setup.exe /S /v/qn"
Dim strMessageTitle      : strMessageTitle = "Software Installation"
Dim strMessage



strMessage = ""
strMessage = strMessage & "Please note that your computer is in the process of receiving" & vbCrLf
strMessage = strMessage & "Adapt PT 2010 and it will prompt you to reboot shortly. This" & vbCrLf
strMessage = strMessage & "is part of an overall update for all the engineers who have" & vbCrLf
strMessage = strMessage & "Adapt PT8.  For any questions with regard to this update" & vbCrLf
strMessage = strMessage & "please contact the service and assign a ticket." & vbCrLf

objWSH.Run strRunCommand, 0, WAIT_FOR_PROGRAM_TO_TERMINATE
MsgBox strMessage, vbOK + vbInformation, strMessageTitle

Open in new window

Commented:
Rob war 1 minute faster...  His script will do the job, Mine is just formated nicer...  points should go to Rob.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Yeah, mine's pretty simplistic.  raiERB, you probably shouldn't wait for the program to terminate before displaying the message, as that would only show the message once it has completed anyway, which would defeat the purpose I imagine.....I would change
Const WAIT_FOR_PROGRAM_TO_TERMINATE = True
to
Const WAIT_FOR_PROGRAM_TO_TERMINATE = False

Regards,

Rob.
Habib ZNetwork Solutions
CERTIFIED EXPERT

Author

Commented:
I was testing the application and it turns out the new application can not get installed without first removing the old version.

The old version removal command line is below.

MsiExec.exe /X{F48F2DD4-DE70-4c4c-a0000}

This will be the first command line and the 2nd one is
Setup.exe /s /v/qn
When this command runs the new application gets installed but I want the small message on the screen that says please note your computer is receiving the new  PT application and it will restart in 5 min. PLease save your work. If you have any questions about this upgrade please contact the service desk at 1800 Xxxxx.

My other question is how can I make it so there is a delay of 3 or 5 min. Can this be done on the script.

I know this was straight forward before but it turned to be more complicated then I thought originally.

Appreciate all you help,

Thank you

Commented:
Here the updated script...  The script will

1. Inform user (and wait until OK has been clicked)
2. Uninstall the program (wait for installation to complete)
3. Install the program (and continue)


Option Explicit
On Error Resume Next

Const WAIT_FOR_PROGRAM_TO_TERMINATE = True
Const DONT_WAIT_FOR_PROGRAM_TERMINATION = False
' Window Type: 0 = Hide, 1 = Activate and Display
Const WINDOW_TYPE = 0

Dim objWSH               : Set objWSH = CreateObject("WScript.Shell")
Dim strScriptPath        : strScriptPath = objWSH.CurrentDirectory
Dim strRunCommand        : strRunCommand = strScriptPath & "\" & "Setup.exe /S /v/qn"
Dim strUninstallCommand  : strUninstallCommand = "MsiExec.exe /X{F48F2DD4-DE70-4c4c-a0000}"
Dim strMessageTitle      : strMessageTitle = "Software Installation"
Dim strMessage


strMessage = ""
strMessage = strMessage & "Please note that your computer is in the process of receiving" & vbCrLf
strMessage = strMessage & "Adapt PT 2010 and it will prompt you to reboot shortly. This" & vbCrLf
strMessage = strMessage & "is part of an overall update for all the engineers who have" & vbCrLf
strMessage = strMessage & "Adapt PT8.  For any questions with regard to this update" & vbCrLf
strMessage = strMessage & "please contact the service and assign a ticket." & vbCrLf

' Inform the user...  Script will wait until user clicks OK
MsgBox strMessage, vbOK + vbInformation, strMessageTitle

' Waits for unisntallation to terminate
objWSH.Run strUninstallCommand, 0, WAIT_FOR_PROGRAM_TO_TERMINATE

' Continues after install command has been run
objWSH.Run strRunCommand, 0, DONT_WAIT_FOR_PROGRAM_TERMINATION

Open in new window

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Habib ZNetwork Solutions
CERTIFIED EXPERT

Author

Commented:
Thanks guys I am testing the scripts. I will let you know what happens
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.