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

MDT Post OSD Batch File

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
Resonetics
Asked:
Resonetics
  • 6
  • 5
  • 2
1 Solution
 
Adam LeinssCommented:
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
 
ResoneticsAuthor Commented:
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
 
Adam LeinssCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ResoneticsAuthor Commented:
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
 
Adam LeinssCommented:
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
 
Mike TLeading EngineerCommented:
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
 
ResoneticsAuthor Commented:
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
 
Mike TLeading EngineerCommented:
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
 
ResoneticsAuthor Commented:
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
 
ResoneticsAuthor Commented:
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
 
Adam LeinssCommented:
Do you have a screenshot of the error?
0
 
ResoneticsAuthor Commented:
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
 
Adam LeinssCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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