vbscript software install

I located a basic script to perform a software install, and it appears there is a syntax error in it which I am not able to sort out.  Line 23 is the problem where the "elseif" statement is.

'===============================================================
 'To check whether the OS is 32 bit or 64 bit of Windows 7
 '===============================================================
 
'Lines to detect whether the OS is 32 bit or 64 bit of Windows 7

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputerName & "\root\default:StdRegProv")
 
   strKeyPath = "HARDWARE\DESCRIPTION\System\CentralProcessor\0"
 
   strValueName = "Identifier"
 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 '===============================================================
 
'Checking Condition whether the build is 64bit or 32 bit
 
   If (instr(strValue,"64")) then
  WshShell.Run "7z920-x64.msi" /qb
'Perform functions for 64-bit OS.
 End If
 
ElseIf (instr(strValue,"x86")) Then
 WshShell.Run "7z920-x86.msi" /qb
'Perform functions for 32-bit OS.
 End If
ResoneticsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KimputerCommented:
Must be a mid-mind jump while writing code.

Just change Elseif to If and the script should work just fine.
0
ResoneticsAuthor Commented:
OK...so I changed it from Elseif to "If" and the syntax error is gone for that line.

It appears there is a problem with the following line at 8,1.

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

C:\Users\%USERNAME%\Desktop\VBInstall\CoverityInstall.vbs(8, 1) (null): 0x80041021
0
KimputerCommented:
You didn't add a value to the variable strComputerName, which is empty at this script at this point (unless I'm missing lines of code above, but you mentioned line 8, so it can't be!).
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

ResoneticsAuthor Commented:
Here's a silly question, what should the value for strComputerName be?
0
KimputerCommented:
Usually, this will do (if script is run on the computer itself, and the line "WshShell.Run" suggests it is):

strComputerName = WshNetwork.ComputerName

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ResoneticsAuthor Commented:
Thanks for the assistance.  It seems to work now.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.