Jump to content


  • 0
Kevin79

Deploy software with batch file

Question

Can I deploy a program that uses a batch file for installation? The batch file calls the installer but also deletes some shortcuts, adds a new shortcut and registers a component. Is this at all possible to do? Is there a better way to do all of this?

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

batch files will most likely fail unless scripted to work in a task sequence (see my offline migration from windows xp to windows 7 post for a batch file example).

 

the best way to script your program installations is with a VBS wrapper script

 

here's a sample installer script for installing windows xp sp3

 

Dim Retval
Retval=0

' *** Install Application. ***
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")

' open normal and don't wait
WSHShell.Run "WindowsXP-KB936929-SP3-x86-ENU.exe /quiet /norestart /log:%temp%\SP3_Install.log", 1, false
Set WSHShell = Nothing

' *** show us what RETVAL is, unrem to see what retval = ***
' MsgBox "The actual return code was " &retval

' *** unrem to set to 3010 for testing ***
'retval = 3010

If retval = 3010 Then
MsgBox "The return code was 3010, resetting to 0"
else
MsgBox "The actual return code was " &retval
WScript.Quit(Retval)
End If



' *** set the return value to 0 anyway. ***
Retval=0
MsgBox "The return code was reset to " &retval
WScript.Quit(Retval) 

Share this post


Link to post
Share on other sites

  • 0

batch files will most likely fail unless scripted to work in a task sequence (see my offline migration from windows xp to windows 7 post for a batch file example).

 

the best way to script your program installations is with a VBS wrapper script

 

here's a sample installer script for installing windows xp sp3

 

Dim Retval
Retval=0

' *** Install Application. ***
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")

' open normal and don't wait
WSHShell.Run "WindowsXP-KB936929-SP3-x86-ENU.exe /quiet /norestart /log:%temp%\SP3_Install.log", 1, false
Set WSHShell = Nothing

' *** show us what RETVAL is, unrem to see what retval = ***
' MsgBox "The actual return code was " &retval

' *** unrem to set to 3010 for testing ***
'retval = 3010

If retval = 3010 Then
MsgBox "The return code was 3010, resetting to 0"
else
MsgBox "The actual return code was " &retval
WScript.Quit(Retval)
End If



' *** set the return value to 0 anyway. ***
Retval=0
MsgBox "The return code was reset to " &retval
WScript.Quit(Retval) 

 

 

I will have to disagree on this one Niall.

 

On our recent major upgrade of Office 2007 i had a problem with Proofing tools that was causing all language to be deployed and installing extra keyboard languages, which was not acceptable. To accomplish this i found the msi deployment for the specific 3 languages that i wanted and link them on a batch file. One thing let to another and i link a company based installation on that that required to add a registry value and delete a folder under Program Files. The batch worked flawlessly.

 

To sum up, .Net deployment 3.5 SP1 could not run since if you run the full setup it will still require to access the internet which was causing problem. So as it was recommended you should extract it and then run 5-6 msi files which i linked each other to install .Net framework :)

 

My 2 cents :)

Share this post


Link to post
Share on other sites

  • 0

i didn't say it wasn't possible i just said it would likely fail (i've seen a lot of failures where people take working batch files and try to use them in configmgr without editing them first)

 

can you do the OP a favor and post your batch file here for us to look at ?

 

cheers

niall

Share this post


Link to post
Share on other sites

  • 0

Sure! Of course when you deploy a program from batch file and your deployment fails at the second setup for example you will have to rerun the batch as a whole again...So you might need to consider that in case something goes wrong, your program can be rerun/repair so your users will not get an error and the execution stucks and you will have to do it manually. I guess this is what Niall is referring.

 

Anyway this is the one i was referring....

 

start /wait Toolbox\BrandTools.EXE
start /wait msiexec /i ProofKit.WW\Proof.el\proof.msi LAUNCHEDBYSETUPEXE=1 /qb
start /wait msiexec /i ProofKit.WW\Proof.en\proof.msi LAUNCHEDBYSETUPEXE=1 /qb
start /wait msiexec /i ProofKit.WW\Proof.ru\proof.msi LAUNCHEDBYSETUPEXE=1 /qb
start /wait regedit /s Toolbox\wizkit.reg
rd /S /Q "C:\Program Files\Wiz-Kit"
start /wait msiexec /i Toolbox\PresentationToolbox.msi /qb /norestart

Installation of programs, add a registry key and remove a directory ^

 

and for the .Net 3.5 deployment, after you have extracted the files as per MS instructions.

start /wait msiexec /i MSXML6_x86\msxml6.msi /qb /norestart
start /wait msiexec /i RGBRAST_x86\RGB9RAST_x86.msi /qb /norestart
start /wait msiexec /i NETFX20_x86\netfx20a_x86.msi /qb VSEXTUI=1 /norestart
start /wait msiexec /i NETFX30_x86\netfx30a_x86.msi /qb VSEXTUI=1 /norestart
start /wait msiexec /i netfx35_x86\vs_setup.msi /qb VSEXTUI=1 /norestart
start /wait NDP35SP1-KB958484-x86.exe /passive /norestart
start /wait vstor30.exe /q

 

Start /wait prevents all setup from running at the same time, instead it start the first one, waits to finish then goes to the second etc.

One last thing though. If you are going to run them from DP directly you might consider using %~dp0 value infront of the command so it can run with UNC (\\server\<path>) cause batch files do not run by default. So......

start /wait %~dp0NDP35SP1-KB958484-x86.exe /passive /norestart

Before i learn this small tip for batch files i used to select "requires drive letter" so it could map the SCCM share on the user computer in order to run "locally"

Share this post


Link to post
Share on other sites

  • 0

i didn't say it wasn't possible i just said it would likely fail (i've seen a lot of failures where people take working batch files and try to use them in configmgr without editing them first)

 

can you do the OP a favor and post your batch file here for us to look at ?

 

cheers

niall

 

Here is the batch file and other batch files it calls...

 

Install.bat

 

@Echo OFF

REM ************************************************************************

REM ** Install SAP Gui 7.10

REM ************************************************************************

 

CLS

Echo SAP Front-End(SapGui) Setup

Echo ===========================

Echo This will install/Upgrade your SAP Gui to Version 7.10!

Echo If you ran this by accident please cancel now.

 

 

CLS

Echo Installing SAP Front-End 7.10(SapGui).

Echo Please wait...

call \\domain\software\sap-gui\7.10\Setup\NwSapSetup.exe /Silent /Package="Company SAP GUI 7.1"

call \\domain\software\sap-gui\7.10\deleteshortcut.bat

call \\domain\software\sap-gui\7.10\IE-SAPFIX.bat

 

 

CLS

Echo

Echo SAP Front-End(SapGui) has been installed.

 

 

:END

Exit

 

deleteshortcut.bat

 

%comspec% /c del "c:\documents and settings\all users\desktop\*saplo*.lnk"

%comspec% /c del "c:\documents and settings\all users\desktop\*saplg*.lnk"

%comspec% /c del "c:\documents and settings\all users\desktop\*sap lo*.lnk"

%comspec% /c del "C:\Documents and Settings\All Users\Start Menu\Programs\*saplo*.lnk"

call \\domain\software\sap-gui\7.10\SAPShortcut.vbs

 

 

SAPShortcut.vbs

 

set WshShell = WScript.CreateObject("WScript.Shell")

set oShortCutLink = WshShell.CreateShortcut("c:\documents and settings\all users\desktop\" & "\SAP Logon.lnk")

oShortCutLink.TargetPath = "C:\Program Files\SAP\FrontEnd\SAPgui\saplogon.exe"

oShortCutLink.WindowStyle = 1

oShortCutLink.Hotkey = "CTRL+SHIFT+N"

oShortCutLink.Description = "SAP Logon"

oShortCutLink.Save

 

 

IE-SAPFIX.bat

 

sapregsv mshtml.tlb /s

 

Any suggestions on how to make this work?

Share this post


Link to post
Share on other sites

  • 0

Here is the batch file and other batch files it calls...

 

Install.bat

 

 

deleteshortcut.bat

 

 

 

SAPShortcut.vbs

 

 

 

IE-SAPFIX.bat

 

 

Any suggestions on how to make this work?

 

ok at first look this will not work call \\domain\

 

so create a packet in SCCM.

 

If your files are resign to \\domain\software\sap-gui\7.10\ then create a new package and for source folder point out to 7.10 folder. This will make it your working directory.

Then create a program for that and for command put Install.bat

 

then replace all call \\domain\software\sap-gui\7.10\ with just call %~dp0 ie

call \\domain\software\sap-gui\7.10\IE-SAPFIX.bat to call %~dp0IE-SAPFIX.bat

 

That should do! it let me know how it goes

 

Cheers

 

Yiannos

Share this post


Link to post
Share on other sites

  • 0

ok at first look this will not work call \\domain\

 

so create a packet in SCCM.

 

If your files are resign to \\domain\software\sap-gui\7.10\ then create a new package and for source folder point out to 7.10 folder. This will make it your working directory.

Then create a program for that and for command put Install.bat

 

then replace all call \\domain\software\sap-gui\7.10\ with just call %~dp0 ie

call \\domain\software\sap-gui\7.10\IE-SAPFIX.bat to call %~dp0IE-SAPFIX.bat

 

That should do! it let me know how it goes

 

Cheers

 

Yiannos

 

I got the actual installer to run but none of the other batch files ran...

Share this post


Link to post
Share on other sites

  • 0

Have you change the path of the other batch files?

 

Can you post them again? What error do you get under your reports?

 

I consolidated the files in to two files.

 

The install file:

%~dp0Setup\NwSapSetup.exe /Silent /Package="SAP GUI 7.1"

%comspec% /c del "c:\documents and settings\all users\desktop\*saplo*.lnk"

%comspec% /c del "c:\documents and settings\all users\desktop\*saplg*.lnk"

%comspec% /c del "c:\documents and settings\all users\desktop\*sap lo*.lnk"

%comspec% /c del "C:\Documents and Settings\All Users\Start Menu\Programs\*saplo*.lnk"

%~dp0SAPShortcut.vbs

sapregsv mshtml.tlb /s

 

SAPShortcut.vbs

set WshShell = WScript.CreateObject("WScript.Shell")

set oShortCutLink = WshShell.CreateShortcut("c:\documents and settings\all users\desktop\" & "\SAP Logon.lnk")

oShortCutLink.TargetPath = "C:\Program Files\SAP\FrontEnd\SAPgui\saplogon.exe"

oShortCutLink.WindowStyle = 1

oShortCutLink.Hotkey = "CTRL+SHIFT+N"

oShortCutLink.Description = "SAP Logon"

oShortCutLink.Save

 

What reports do you mean?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.