Sign in to follow this  
Followers 0
tuvi123

simple script DOES NOT work

3 posts in this topic

I want to make a script that automatically change my office key.

:) here is my script but it does not work:

#RequireAdmin

If @OSArch = "X64" Or "IA64" Then

$key = "HKLM64"

Else

$key = "HKLM"

EndIf

$var = RegRead($key & "SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot", "Path")

runWait('cscript.exe '$var & "ospp.vbs /inpkey:VYBBJ-TRJPB-QFQRF-QFT4D-H3GVB"'', '', @SW_HIDE)

Exit

it does not work..

if I open CMD and run

cscript "%PROGRAMFILES%\Microsoft Office\Office14\ospp.vbs" //b /inpkey:VYBBJ-TRJPB-QFQRF-QFT4D-H3GVB

it works.

the "Path" value in the registry is "C:\Program Files\Microsoft Office\Office14\"

(mods the KEY is microsoft betatrial key, so it's legit so don't remove this thread)

I have also tried this:

runWait(@COMSPEC & " /c " & ""$var"\ospp.vbs /inpkey:VYBBJ-TRJPB-QFQRF-QFT4D-H3GVB", @SW_HIDE)

runWait(@comSpec & ' /c cscript.exe '$var & "ospp.vbs /inpkey:VYBBJ-TRJPB-QFQRF-QFT4D-H3GVB"'', '', @SW_HIDE)

runWait('cscript.exe "'$var'\ospp.vbs" /inpkey:VYBBJ-TRJPB-QFQRF-QFT4D-H3GVB', @SW_HIDE)

ShellExecute($var & "ospp.vbs", "/inpkey:VYBBJ-TRJPB-QFQRF-QFT4D-H3GVB", "", "", @SW_HIDE)

but it does not work.

I get "Error:Error in expression Line" in that line.

please help me.

B):D;):):(

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe this works?

#RequireAdmin
$key = "HKLM"
If StringInStr(@OSArch,"64") then $key = "HKLM64"
$var = RegRead($key & "\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot", "Path")
runWait("cscript.exe """ & $var & "\ospp.vbs"" //b /inpkey:KEY",$var, @SW_HIDE)
Exit
Edited by KaFu

Share this post


Link to post
Share on other sites

I get "Error:Error in expression Line" in that line.

It is a (by your code) concatenate error i.e missing the char "&" which joins the parts of strings, variables etc. together.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0