Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

.vbs code to read registry does not run on Windows 2003, 64 bit

Posted on 2010-11-24
4
Medium Priority
?
504 Views
Last Modified: 2012-05-10
HI,

I have a snippit of .vbs that runs fine on ever XP or windows 2003 32 bit machine I have tested it on. It even works on windows 2003 64 if I run it in the vbedit debugger.

It just doesn't work when I run it from a DOS command line using wscript

I am guessing this is some sort of permissions issue, but I am not sure what
const HKEY_CURRENT_USER = &H80000001
	const HKEY_LOCAL_MACHINE = &H80000002
	strComputer = "."
	Set StdOut = WScript.StdOut
 
	Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
 	strComputer & "\root\default:StdRegProv") 
 
 	'reg key for .net 2.0 SP1 and SP2
	strKeySp1Path = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B508B3F1-A24A-32C0-B310-85786919EF28}"
	strKeySp2Path = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C09FB3CD-3D0C-3F2D-899A-6A1D67F2073F}"
	strValueName = "DisplayName"
	
	'We will only install .net 2.0 SP1 if it is not superceeded. 
	'first see if 2.0 SP2 is installed
	oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeySp2Path,strValueName,strSp2Value	
	If IsNull(strSp2Value) Or Len(strSp2Value) = 0 Then
		oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeySp1Path,strValueName,strValue

Open in new window

0
Comment
Question by:Christopher Schene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:trythisone
ID: 34207658
Try thise things:

Open the command prompt as an administrator:
Right click on the icon and select run as administrator

Try using cscript instead of wscript

Make sure that the key that you are looking for exists.

Does it return an error when it fails?
0
 

Accepted Solution

by:
Christopher Schene earned 0 total points
ID: 34243966
I do believe I figured out what the problem is: I need to run the 64 bit version of wscript.exe rather than the 32 bit version.

I am not sure why this makes a difference, but it fixes the problem
0
 

Author Comment

by:Christopher Schene
ID: 34934373
Could someone close this question? I answered my own question.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

647 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question