• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

Need a batch file

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,
0
Zak Z
Asked:
Zak Z
  • 3
  • 3
  • 2
1 Solution
 
RobSampsonCommented:
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

0
 
raiERBCommented:
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

0
 
raiERBCommented:
Rob war 1 minute faster...  His script will do the job, Mine is just formated nicer...  points should go to Rob.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
RobSampsonCommented:
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.
0
 
Zak ZNetwork AnalystAuthor 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
0
 
raiERBCommented:
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

0
 
RobSampsonCommented:
Hi, you can try this too, which will wait three minutes before doing anything, then run the uninstall command, then start the install, and display the message box to the user.

Regards,

Rob.
' Wait for three minutes before doing anything
WScript.Sleep 180000
Set objShell = CreateObject("WScript.Shell")
objShell.Run "MsiExec.exe /X{F48F2DD4-DE70-4c4c-a0000}", 1, True
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

0
 
Zak ZNetwork AnalystAuthor Commented:
Thanks guys I am testing the scripts. I will let you know what happens
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now