/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


I need help converting a batch file to VBScript!

03/19/2015 2137 views

If possible, can anyone PLEASE lead me in the right direction with converting this batch code to VBS? Thanks!

--------------------------------------------------------

@ECHO OFF
ECHO Removing the previous SQL Native Client installation.
MsiExec.exe /x{D411E9C9-CE62-4DBF-9D92-4CB22B750ED5} /passive /norestart /log "C:\Temp\Synchro\SQL_Remove.log"

CD C:\Temp\Synchro

ECHO Installing the Synchro 9 suite prerequisites...
msiexec /i 1_sqlncli_64.msi /passive IACCEPTSQLNCLILICENSETERMS=YES /log "C:\Temp\Synchro\SQL_Native.log"

msiexec /i 2_SqlLocaLDB_64.msi /passive IACCEPTSQLLOCALDBLICENSETERMS=YES /log "C:\Temp\Synchro\SQL_LocalDB.log"

msiexec /i 3_SqlCmdLnUtils_64.msi /passive /log "C:\Temp\Synchro\SQL_CMD_Utils.log"

ECHO Installing the Synchro 9 suite...

Start /wait /HIGH setup.exe /S

del /f "C:\Users\Public\Desktop\Synchro 9.lnk"
del /f "C:\Users\Public\Desktop\SimTraffic 9.lnk"
del /f "C:\Users\Public\Desktop\3DViewer 9.lnk"
del /f "C:\Users\Public\Desktop\TripGen 2014.lnk"
del /f "C:\Users\Public\Desktop\Warrants 9.lnk"
del /f "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\3DViewer 9.lnk"
del /f "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\SimTraffic 9.lnk"
del /f "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\Synchro 9.lnk"
del /f "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\TripGen 2014.lnk"
del /f "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\Warrants 9.lnk"

ECHO The installation process has completed successfully.

 

1 Comment   [ + ] Show comment

Comments

  • Grab yourself a copy of the Windows Scripting Host download which comes with a help file that has dozens of code examples you can adapt to your requirements

All Answers

0
A better conversion would be to power-shell  it is rapidly replacing vb-script and it has a lot more power

Write-host "Removing the previous SQL Native Client installation."
& MsiExec.exe /x{D411E9C9-CE62-4DBF-9D92-4CB22B750ED5} /passive /norestart /log "C:\Temp\Synchro\SQL_Remove.log"

CD C:\Temp\Synchro

Write-host "Installing the Synchro 9 suite prerequisites..."
& msiexec /i 1_sqlncli_64.msi /passive IACCEPTSQLNCLILICENSETERMS=YES /log "C:\Temp\Synchro\SQL_Native.log"

& msiexec /i 2_SqlLocaLDB_64.msi /passive IACCEPTSQLLOCALDBLICENSETERMS=YES /log "C:\Temp\Synchro\SQL_LocalDB.log"

& msiexec /i 3_SqlCmdLnUtils_64.msi /passive /log "C:\Temp\Synchro\SQL_CMD_Utils.log"

write-host "Installing the Synchro 9 suite..."

& Start /wait /HIGH setup.exe /S

Remove-Item -Path "C:\Users\Public\Desktop\Synchro 9.lnk" -Force
Remove-Item -Path  "C:\Users\Public\Desktop\SimTraffic 9.lnk" -Force
Remove-Item -Path "C:\Users\Public\Desktop\3DViewer 9.lnk" -Force
Remove-Item -Path  "C:\Users\Public\Desktop\TripGen 2014.lnk"  -Force
Remove-Item -Path  "C:\Users\Public\Desktop\Warrants 9.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\3DViewer 9.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\SimTraffic 9.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\Synchro 9.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\TripGen 2014.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\Warrants 9.lnk"  -Force

write-host "The installation process has completed successfully."
Answered 03/25/2015 by: dcookBE
Senior White Belt

0
convert it to power shell instead 
Write-host "Removing the previous SQL Native Client installation."
& MsiExec.exe /x{D411E9C9-CE62-4DBF-9D92-4CB22B750ED5} /passive /norestart /log "C:\Temp\Synchro\SQL_Remove.log"

CD C:\Temp\Synchro

Write-host "Installing the Synchro 9 suite prerequisites..."
& msiexec /i 1_sqlncli_64.msi /passive IACCEPTSQLNCLILICENSETERMS=YES /log "C:\Temp\Synchro\SQL_Native.log"

& msiexec /i 2_SqlLocaLDB_64.msi /passive IACCEPTSQLLOCALDBLICENSETERMS=YES /log "C:\Temp\Synchro\SQL_LocalDB.log"

& msiexec /i 3_SqlCmdLnUtils_64.msi /passive /log "C:\Temp\Synchro\SQL_CMD_Utils.log"

write-host "Installing the Synchro 9 suite..."

& Start /wait /HIGH setup.exe /S

Remove-Item -Path "C:\Users\Public\Desktop\Synchro 9.lnk" -Force
Remove-Item -Path  "C:\Users\Public\Desktop\SimTraffic 9.lnk" -Force
Remove-Item -Path "C:\Users\Public\Desktop\3DViewer 9.lnk" -Force
Remove-Item -Path  "C:\Users\Public\Desktop\TripGen 2014.lnk"  -Force
Remove-Item -Path  "C:\Users\Public\Desktop\Warrants 9.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\3DViewer 9.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\SimTraffic 9.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\Synchro 9.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\TripGen 2014.lnk"  -Force
Remove-Item -Path  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Trafficware\Warrants 9.lnk"  -Force

write-host "The installation process has completed successfully."

Answered 03/25/2015 by: dcookBE
Senior White Belt

0
 Convert to power shell instead 

Answered 03/25/2015 by: dcookBE
Senior White Belt

0

I'm a bit of a purist so would abandon the calls to MSIExec and use the Windows Installer Object Model to do the uninstalling but that is a whole different level of scripting.

First of all, *why* do you want to convert the command file to VBS?

Second, there are a quadzillion examples of VBSes which execute a program or programs out there that could easily be adapted. A good place to start would be www.computerperformance.com.

The golden rule of scripting (which your command file ignores) is to error-trap everything. Never - EVER - assume that each line of code will execute successfully. Build robustness in from Day One.

Answered 03/20/2015 by: VBScab
Red Belt

0
https://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.85).aspx

Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "cmd /K CD C:\ & Dir"
Set oShell = Nothing

Answered 03/20/2015 by: aragorn.2003
Red Belt

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ