SCCM 2012 and Windows Batch Scripts as Deployment Types

Hi guys,
I hope you are all well and can help.
Please pardon my ignorance on this, as Im not an SCCM guru.

But what we are trying to do is:
Deploy Office 2013 (click to run) as a package in SCCM, and attach a post install script to this package to immediately execute after installation of Office. This post install script is a .cmd batch file.

Will SCCM allow this .cmd file to be used as a post install script, that is, as a deployment type, or does SCCM not support batch files?

The SCCM guy that is doing this is having difficulty getting the .cmd file to execute after the office installation has run, so the obvious question is, does SCCM support batch files? I would have thought so, but maybe not, or maybe the way the SCCM application is configured is not correct.

I want to know definitively that SCCM either does support batch files eg.cmd and bat files, or it does not, which will mean we will have to convert our script to vbscript or powershell, but this would be a last resort.

Thanks guys.
LVL 1
Simon336697Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Yes, SCCM can deploy cmd. At least three possibilities come to mind to do what you want:
* 1. You can create one package, consisting of both the office sources and a batch script that is used as an install program.
The batch script first starts the Office setup, and then does whatever you want to do once the setup returns.
* 2. You can create two separate packages: one for Office, one for the batch script.
Then you have two ways to continue:
* 2.a. In the properties of the install program for the batch package, select the Office package as "Run another program first", then deploy the batch (not Office).
* 2.b. Create a task sequence with the two packages, then deploy the task sequence.
Simon336697Author Commented:
Hi oBdA,
You have always been brilliant in answering questions. Thanks again for the upteenth time :>)
Im not a guru on SCCM and will get the SCCM guy to look at your answers tomorrow.

I know I believe he is trying to do this.

Create an application that first kicks off the Office 365 install (it is not an msi, it is click to run version), then to fire a .bat file directly after office 365 install, and I believe to do that, he is adding the .bat file as a deployment type if that makes sense. This .bat file contains a lot of "reg add xxxxx" settings, and he tells me that it is not running.

This is what we are trying to solve.

Thanks so much for your kind help :>)
Mike TLeading EngineerCommented:
Hi,

The answer to your question is yes, SCCM does support bat files. The option is a custom script in the application wizard or a traditional package which does not care about the command being run. Applications are much richer and support many more options than packages.

The bigger question is why are you using bat files in 2015. Do you have error trapping or back out logic?

If you tell us what the bat file is doing we can suggest options.
Options are
A) If you are just running reg add then why not put that key into the Office admin wizard.
B) Use PowerShell
C) Use vbscript

The orig question quotes office 2013, but your reply to the other expert mentions office 365. If so a is not relevant.

Options with script if you must use a script (note this is the same as dba's answer but with more detail in option 1


1 Write a full script to run the Office install and then add registry keys etc. PowerShell or vbscript can both return result codes to SCCM. You create a custom application with a script deployment type that will have to have custom Detection Methods to check a file exists, with version x, and a second DM to check one or more of the extra registry keys.

2 use a task sequence as dba  suggests above.

The detection method is vital. Otherwise SCCM has no idea if the delivery worked or not. That is how it reports success or fail in the logs or console.

Mike

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Simon336697Author Commented:
Thanks Mike.

One issue the guy doing this SCCM deployment is, is getting the following to execute.


----------------------------------- script1.cmd

----------------------------------- script2.cmd

cscript testscript.vbs /item:arg1 arg 2


So, in the above, he is trying to kick off multiple batch files.

script1 executes, but the vbscript in script2.cmd does not.

is there a specific escape sequence or escape character that needs to done here?

My gut tells me it is not recognising the arguments that follow the vbscript.
Mike TLeading EngineerCommented:
Hi,
So script1.cmd runs fine and has normal commands in. Script2.cmd errors and contains just the vbscript?

There are no escape codes. Can you attach the two scripts please. You can run the vbscript as a run command line instead, including parameters so I am bemused why you have a bat file.

Mike
Simon336697Author Commented:
Hi Mike T,

Sorry for the delay getting back to you mate.

I have attached an image file that details each script.

The issue we are having is pin_start_menu_fix.cmd, with the pinitems.vbs.
scriptsRunning.bmp
oBdACommented:
The issue is that the SCCM client can't find pinitems.vbs. When you start anything via SCCM, the working directory is C:\Windows\system32.
"cd P:\ath" only sets the working directory for the drive specified; if you're currently on drive C: (which you are in SCCM deployments), and enter "cd D:\Wherever", you'll stay on drive C:.
Use "cd /d D:\Support\...", or use the full path when starting the VB script, as in "cscript.exe D:\Support\Installs\o365_v15_x86\pinitem.vbs ...".
Mike TLeading EngineerCommented:
Hi - I will reply at length tonight but...

I know old habits are hard to break but please, please stop using BAT files. They are not scripts either, they are command lines.
You can run ALL the things you want as separate task-sequence steps. This will give you more control, proper reporting and bring you into the modern world :). Trust me it will make your life easier.

Mike
Mike TLeading EngineerCommented:
Hi,

Script 1: Office365
Create a application with deployment type script to allow you to reference the EXE.
At the command step in the wizard just enter your command *without* the path,
e.g.

setup.exe /configure O365PPlusNoAccess_x86.xml

The source path must just contain all the files, e.g.

\\unc\share\Microsoft\O365_v15_x86
Setup.exe
O365PlusNoaccess_x86.xml
<dir1>
<dir2>

Script 2: Pin startmenu

create a new folder for all custom vbscripts
Add the VBS scripts to the UNC path
create a new package pointing to your script folder
do not create a command line, just point to the UNC path
Add a new step to the ts, type Run command line
below the command line, browse for the script package
in the command line enter
cscript.exe pinitem.vbs /item:%Programfiles%\Microsoft Office 15\root\Office15\Excel.exe
repeat for PowerPoint and Word so you have 3 steps added to the ts

Note: the logging is unnecessary because everything will be logged by SCCM instead now.

Script 3: Office 365 no access
the steps above replace ALL the CMDs you call so only the xcopy job is needed however I can't work out what it is trying to do.

To run xcopy in the task-sequence use run command line and
in the command line enter the xcopy command as
xcopy /q /y *.* <dest>

note your xcopy has a mistake. It has *.* twice, copying whatever is in the current path to D:\ which is presumably where the source files are already??


Script 4 - hide Outlook

in a task-sequence normal environment variables will not exist. So the first two lines will never run anyway.

You can replace the whole "if exist" with a condition on a task-sequence step so just add a single step run command line with a condition to look for outlook.lnk
and then put
cmd /k del %programdata%\...etc\outlook.lnk


That's it. CMD scripts have been banished and the master calling script is not even needed.

I hope that all makes sense. Any issues I can explain with a screenshot.

Mike
Simon336697Author Commented:
Thank you so very much Mike. That is so very thorough. Very well explained and I will listen to your advice. I haven't had a chance to test this yet, but ahead of time, thanks so much for your kind and great input here. Very much appreciated mate.
oBdA.
I cant forget you as well mate.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Office 365

From novice to tech pro — start learning today.