Can someone explain this to me? I'm seeing different behavior on two similar PCs depending on whether I run a VBScript or run that same script within a Wise-created EXE.

My PC is Windows XP Professional x64 Edition, Version 2003, Service Pack 2.
I'm trying to read the "Install" value (a dword value) for registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1. This key exists both on my PC and a test PC, which is also XP Pro 64 bit, etc.

This is the VBScript I'm using:

Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\PowerShell\1"
strValueName = "Install"
oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
MsgBox "Install value is: " & dwValue


Don't have error handling built in yet because I'm still testing.

This script reports back the value of "Install" correctly both on my PC and the test PC. So far so good.

Next I wrote a Wise package (using Wise Package Studio 8) with the WiseScript Package Editor. It copies the VBScript locally and then runs it. Here's the Wise code:

item: Set Variable
Variable=C
Value=C:
end
item: Install File
Source=.\MSI\script\dword.vbs
Destination=%C%\test\dword.vbs
Flags=0000000010100010
end
item: Execute Program
Pathname=%C%\test\dword.vbs
Flags=00000010
end


I compile in Wise to an EXE and then run it. On my PC the message box shows me the correct value for "Install", which is "1." But on my test PC, it doesn't report back any value at all. So I'm not sure why the VBScript behaves correctly on both PCs, but calling the VBScript via a Wise-created EXE results in my PC reporting correctly and the other not. I've tested against a third 64 bit XP machine, also, just to make sure my results weren't a fluke.

What I'm trying to do specifically is check if PowerShell is installed on a PC. I realize that for this particular example I can also check if the directory exists in Wise, but for my particular task at hand, there will be instances when I have to check the registry, and right now I know of no reliable way to do it when my target PC is 64 bit.

Also, I can't run the VBScript directly without benefit of the Wise EXE. The Wise EXE I'm working on will ultimately install several applications and make a number of user configuration changes for one of the business groups at my company.

So my ultimate question is: how do other packagers who use Wise Package Studio handle working with the registry on a 64 bit PC? I've tried multiple ways of doing this, also using the JSWare.net WMI Registry Class files (http://www.jsware.net/jsware/scripts.php5#wmirclas), with the same end result: the VBscript works correctly on my PC (running the Wise EXE, that is), but not the test PC.
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
One, you should probably delete the other instances of this post.

Two, why not build your installer in script and compile THAT to an EXE using one of the many VBS-to-EXE converters?
Answered 05/05/2011 by: VBScab
Red Belt

Please log in to comment
0
Hello,

The reason could be that when your VBS script is run by the WiseScript exe, it is running as a 32 bit process and consequently can only access the 32 bit part of the registry, whereas your script needs to access the 64-bit registry. AFAIK, WiseScript EXE's have no 64-bit support (and in all probability never will have).

There is some related information in this forum thread specifically around the use of the __ProviderArchitecture flag to WMI as a workaround.

Regards

Spartacus
Answered 05/05/2011 by: spartacus
Black Belt

Please log in to comment
0
Will look into both replies. Also, not sure why this topic posted multiple times. How do I delete those extraneous postings?
Answered 05/05/2011 by: RonW
Green Belt

Please log in to comment
0
How do I delete those extraneous postings?Click the link then click the 'Delete' link. If any have replies, I don't think you can delete them, although you could probably ask Bob (Kelly) - the board's "owner" - to do that for you.
Answered 05/05/2011 by: VBScab
Red Belt

Please log in to comment
0
Not seeing any delete link in those other two posts, other than "Delete My Own Post" and "Delete My Own Thread" at the very bottom right of the pages, although those aren't links and don't do anything. Am I really in that much need of new glasses?
I'll message Mr. Bob Kelly and ask him to remove the duplicates.
Answered 05/05/2011 by: RonW
Green Belt

Please log in to comment
Answer this question or Comment on this question for clarity