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

Need to convert a BAT to VBS, JS or PowerShell

I need to take a batch file that simply changes the license key in MS Office and convert it to something that will keep the license key contained so that nobody can view it..Meaning, it cannot extract the bat file, run it and delete the bat. I would need it to be fully self contained so that there is no way for an end user to view it.

cd Program Files (x86)\Microsoft Office\Office14
cscript ospp.vbs /inpkey:11111-11111-11111-11111-11111
cscript ospp.vbs /act

Open in new window

My first attempt was a converting a bat to exe but the exe was just a self extracting file that ran and deleted the bat. This does not work for my needs.

Second attempt is using Advanced Installer to create an msi ran as administrator. I created a custom action that launches a file. The file to launch would be cscript ospp.vbs. the command line would be /inpkey:11111-11111-11111-11111-11111. and the working directory is C:\Program Files (x86)\Microsoft Office\Office14\.
This attempt returns an error: There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected.
I removed the check mark for: Fail installation if custom action returns an error.
Still didn't work..

So my next option is to do a Custom Action that Executes inline script code. This allows VBS or JS. I also have the option for PowerShell. So I would like to know if anyone can create me either a VBS, JS or PowerShell script that mimics the code above.
1 Solution
Your msi configuration is incorrect.
File to launch needs to be

Open in new window

Command line needs to be
"C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" /inpkey:11111-11111-11111-11111-11111

Open in new window

(including the quotes around the Office path).
prologic08Author Commented:
Ha! You were right (obviously). Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now