• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

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
0
Resonetics
Asked:
Resonetics
  • 3
  • 3
2 Solutions
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
ResoneticsAuthor Commented:
Thanks for the assistance.  It seems to work now.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now