Avatar of prologic08
prologic08
 asked on

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.
ProgrammingVB ScriptPowershell

Avatar of undefined
Last Comment
prologic08

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
oBdA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
prologic08

ASKER
Ha! You were right (obviously). Thanks!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes