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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VScript Issue with Reg Keys

Status
Not open for further replies.

RBEZZINA

Technical User
Jul 13, 2011
3
MT
Hi,

I need a VBScript to do the below.

Check whether this Reg Key Value and Data exist:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Outlook\bitness

if value is 'x64' then it will install A.exe from a specific link. if the value is 'x32' then it will install B.exe from a specific link.

IfHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Outlook\bitness doesn't exist then it will terminate.

Thanks and pls help.

 
How you go about this will depend if the script that reads this key is run against a local registry or remote registry. It's fairly simple. The following link will give you several examples on how to determine if a key exists and what the value it.


-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
This will be run via GPO so that we install some add-ons. Therefore it will run against a remote registry.
 
GPOs are brought down and applied locally.
As the link above suggests...

Code:
Const HKLM = &H80000002

strComputer = "."
set objReg=GetObject("winmgmts:impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
  
strKeyPath = "SOFTWARE\Microsoft\Office\14.0\Outlook"
strValueName = "bitness"
objReg.GetStringValue HKLM, strKeyPath, strValueName, strValue

if (strValue = "x64") then
   'install 64-bit
else
   'install 32-bit
end if

-Geates


"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Will this be good:

Const HKLM = &H80000002

strComputer = "."
set objReg=GetObject("winmgmts:impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Office\14.0\Outlook"
strValueName = "bitness"
objReg.GetStringValue HKLM, strKeyPath, strValueName, strValue

if (strValue = "x64") then
\\servername\folder\install1.msi
else
\\servername\folder\install2.msi
end if
 
Logically, yes. programmatically, no. you'll need to add a shell object to run the msi's. Additionally, you'll probably need to run the msi's by passing it to msiexec, just like on the command line.

Code:
Const HKLM = &H80000002

strComputer = "."
set objReg=GetObject("winmgmts:impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
[green]set objShell = CreateObject(WScript.Shell")[/green]

strKeyPath = "SOFTWARE\Microsoft\Office\14.0\Outlook"
strValueName = "bitness"
objReg.GetStringValue HKLM, strKeyPath, strValueName, strValue

if (strValue = "x64") then
   [green]objShell.Run "msiexec /i ""\\servername\folder\install1.msi"""[/green]
else
   [green]objShell.Run "msiexec /i ""\\servername\folder\install2.msi"""[/green]
end if

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top