Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript: 2 Problems in Script that changes Visio Key

Status
Not open for further replies.

simonster

MIS
Aug 7, 2007
10
0
0
CH
First of all: You are about to read a really stupid question now. I am a beginner in VBS, so please forgive me ;-)

What I want to do with my script:

Check in registry, if Visio is installed
If yes: Change the key to the stated visio key

I want to run this script in a group policy (machine) which is run on startup.

What is not working?

The script returns always 'not existent' even if the key exists
If I run only the ospp.vbs part of the script (which should write the Visio key), it doesnt change anything.

It doesn't matter, if I run this script over GPO or directly as administrator on the client. Sooooo... here's the script:

Code:
Option explicit
Dim sKey, bFound, objShell
skey = "HKEY_LOCAL_MACHINE\SOFTWARE\VAL_3.7\MSVisioProf2010_ENG"

with CreateObject("WScript.Shell")
    On error resume next   
    sValue = .regread(sKey)       ' read attempt
    bFound = (err.number = 0)     ' test for success
  on error goto 0                 ' restore error trapping
end with

if bFound then
  wsh.echo "Found:", sValue
  Set objShell = WScript.CreateObject ("WScript.shell")
  objShell.run "cscript " & Chr(34) & "C:\Program Files (x86)\Microsoft Office\Office14\OSPP.vbs" & Chr(34) & "/inpkey:7MCW8-VRQVK-G677T-PDJCM-Q8TCP"

 else
  wsh.echo "Not found"
end if

Set objShell = Nothing

Thank you very much for your help!

Cheers, Simon
 
When testing scripts it is best to temporarily remove (comment out) the "on error resume next" statement(s) and add message boxes or other output so that you see what is happening.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top