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\
c:
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.
prologic08Asked:
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:
Your msi configuration is incorrect.
File to launch needs to be
C:\Windows\system32\cscript.exe

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).
0

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
prologic08Author Commented:
Ha! You were right (obviously). Thanks!
0
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
Programming

From novice to tech pro — start learning today.