Solved

MDT Post OSD Batch File

Posted on 2014-11-12
13
322 Views
Last Modified: 2014-11-14
I am in the process of incorporating a token based activation script into the OS Deplyoment process.

Our image contains a provision to look for and run a file called "custom.bat" if present.  It provides us with an option to customize and install software after the OS is installed.

I am currently able to run the script to activate the OS, which works fine.

The deployment share contains a scripts folder, which is where I have added the Leaf Certificate and Digital License for Windows 7 Enterprise.

I have created a subfolder called "Office2010Activation" and placed all of the necessary files in it.

My question is how to properly call the batch file within it.  I tried to use relative paths and it cannot find the path specified.

The batch file to activate Office 2010 must be called with this syntax:  %windir%\SYSWOW64\cmd.exe /c
Capture.JPG
0
Comment
Question by:Resonetics
  • 6
  • 5
  • 2
13 Comments
 
LVL 22

Expert Comment

by:Adam Leinss
ID: 40437359
Is this folder on the C: drive?  All you should have to do is add a custom action in the task sequence and just put the path to the batch file there.
0
 

Author Comment

by:Resonetics
ID: 40437378
The folder is part of the deployment share, and lives in the "Deploy\Scripts" folder.

Custom.bat lives in "Deploy/Scripts.

The office 2010 Activation script lives in "Deploy\Scripts\Office2010Activation"

The custom.bat file is the easiet way as it's already setup and doesn't require modifying the task sequence.

Is it possible to call the script by using the following:

"cscript.exe %SCRIPTROOT%\Office2010Activation\activate_Office2010.bat"
0
 
LVL 22

Expert Comment

by:Adam Leinss
ID: 40437403
I believe you can just use %SCRIPTROOT%\Office2010Activation\custom.bat.  Put the word "pause" in the batch file and you should see it running as part of the deployment.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:Resonetics
ID: 40438051
I tried this:

%windir%\SYSWOW64\cmd.exe /c %SCRIPTROOT%\Office2010Activation\activate_Office2010.bat  

And it found the path to the script and ran it.  However, the script doesn't see the digital license file and Leaf certificate located in "Deploy\Scripts\Office2010Activation"

The error is ospp.vbs:  cannot find <leaf certificate name>
0
 
LVL 22

Accepted Solution

by:
Adam Leinss earned 500 total points
ID: 40438218
It's probably setting the working directory to the C: drive, you will probably have to modify the batch file as well to include the path %SCRIPTROOT%\Office2010Activation\
0
 
LVL 17

Expert Comment

by:Mike T
ID: 40439559
Hi,

I have to chip in as a number of things are wrong here not least this: "cscript.exe %SCRIPTROOT%\Office2010Activation\activate_Office2010.bat". This is so wrong. Cscript.exe is a script engine. You use it to run vbscript files. You do not use it to run batch files ever.

Second thing: running batch files in a deployment is a bad idea. Why? Because you have no control and ConfigMgr will get no return code to know if it worked or not.

Third: Installing Office with a BAT file is not good either anyway.

The supported way is to either create an XML or a MSP:
 
The Office Customization Tool (OCT) is used to create a Setup customization file (.msp file). Setup applies this file when Office is installed on the computers.


It is also possible to use the Config.xml file to configure a silent installation of Office Professional Plus 2010. For more information about how to use Config.xml, see Configure a silent installation of Office 2010.
 

Ref: http://technet.microsoft.com/en-us/library/ff404178(office.14).aspx

or this walkthrough for 2012:
http://blogs.technet.com/b/elie/archive/2012/05/08/deploy-office-2010-using-system-center-2012-configuration-manager.aspx

This way avoids any issues with BAT files, paths etc.

As for *activation* the same applies. Do not use BAT files. There are two ways:
1) use KMS
2) use the internet

KMS way
Create an MSP file and configure it to use a KMS server and then make sure you have installed the Microsoft Office 2010 KMS Host License Pack
Downloaded it from  http://www.microsoft.com/downloads/details.aspx?familyid=97B7B710-6831-4CE5-9FF5-FDC21FE8D965&displaylang=en
(as per Kent Agerlund)

Non-KMS way
Use the Office Customisation Tool and just add the property name "AUTO_ACTIVATE" with a value "1" to the "modify setup properties".

Either way, you do NOT need a script to activate Office.

For ConfigMgr please avoid BAT files. Yes, you have it already written and it works, but it works outside of ConfigMgr which behaves (does it's thing) in different way to normal. BAT files quickly get messy and you can spend more time troubleshooting than if you just converted to VBS or PowerShell. If you don't know those, then learn them. Which would you rather do - learn more skills or sit scratching your head wondering why ConfigMgr is not obeying your BAT file?

Mike
0
 

Author Comment

by:Resonetics
ID: 40440110
Mike...I believe you either misunderstand what I am trying to do, or don't know what token based activation is.  These are CLOSED area computers that do not connect to the internet, ever.

The scripts were provided by Microsoft, and I worked with them during the process.

We are not installing Office with  a .bat file, but we are ACTIVATING it with a .bat file.
0
 
LVL 17

Expert Comment

by:Mike T
ID: 40440501
Hi,

It is the latter - I confess I don't know what token based activation is, however, having said that I have found BAT files to be a major pain in the you-know-what.

I know you're also not installing Office, but I was covering all the bases as it just sounded like you are not using an XML or an MSP. That was a guess on my part. Apologies if I put 2 and 2 together and got 43. I have just looked and yes activation is allowed by a third way: token and it's only available on bended knee to Microsoft so I've learnt something :).

With regards the BAT file, can you post the actual contents? It's hard to troubleshoot a blind script. I do know that adding paths to the path field generally doesn't do what you think so again best avoided.

Mike
0
 

Author Closing Comment

by:Resonetics
ID: 40440940
Your tip allowed me to figure out the remainder of the script.  It is now working as expected.

I would post the script, but it contains sensitive information.
0
 

Author Comment

by:Resonetics
ID: 40442440
Well....I thought I was home free.

The last line of the Office Activation Script failed.

cscript.exe %officehome%\ospp.vbs /tokact:9956B2EB8E96CBF2B64456C170033630FFC15097

The %OFFICEHOME% variable is defined based on architecture earlier in the script.  Everything works perfect if run manually.
0
 
LVL 22

Expert Comment

by:Adam Leinss
ID: 40442449
Do you have a screenshot of the error?
0
 

Author Comment

by:Resonetics
ID: 40442614
I figured it out.  It was the way I was calling the Activate_Office2010.bat script.

I had been using:

%windir%\SYSWOW64\cmd.exe /c %SCRIPTROOT%\Office2010Activation\activate_Office2010.bat

I dropped the first part completely
So it'sjust %SCRIPTROOT%\Office2010Activation\activate_Office2010.bat

And that works.

Thanks again.
0
 
LVL 22

Expert Comment

by:Adam Leinss
ID: 40442714
Ah...I'm guessing %SCRIPTROOT% is defined in the first command environment, but when you start cmd a 2nd time you get another set of environmental variables.  You could test this theory by using the commands set and pause.  SET should show you the variables defined and pause allows you to see the command output before closing.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had a hard drive that you can't boot into, but need to change the registry? Here is the solution! This article guides you through accessing and editing a registry of a non-primary drive. To read registry information on a non-prim…
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question