1

7zip (x86 および x64) 用の 2 つの .msi インストーラーをダウンロードしました。OS アーキテクチャを検出し、適切な .msi ファイルを起動するために使用できる簡単なスクリプトを持っている人はいますか?

4

4 に答える 4

1

これは役立つかもしれません

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessors = objWMIService.ExecQuery _
  ("Select * From Win32_Processor")

For Each objProcessor in colProcessors
  If objProcessor.Architecture = 0 Then
    Wscript.Echo "This is an x86 computer."
  ElseIf objProcessor.Architecture = 1 Then
    Wscript.Echo "This is a MIPS computer."
  ElseIf objProcessor.Architecture = 2 Then
    Wscript.Echo "This is an Alpha computer."
  ElseIf objProcessor.Architecture = 3 Then
    Wscript.Echo "This is a PowerPC computer."
  ElseIf objProcessor.Architecture = 5 Then
    Wscript.Echo "This is a ARM computer."
  ElseIf objProcessor.Architecture = 6 Then
    Wscript.Echo "This is an ia64 computer."
  ElseIf objProcessor.Architecture = 9 Then
    Wscript.Echo "This is an x64 computer."
  Else
    Wscript.Echo "The computer type could not be determined."
  End If
Next
于 2012-07-03T04:16:08.720 に答える
1

Microsoft Technet に投稿された、Monimoy Sanyal によって作成された優れた vbscript を見つけました。また、32 ビット システムが 64 ビット ハードウェアで実行されている場合、システム アーキテクチャに関する情報も提供します。 https://gallery.technet.microsoft.com/scriptcenter/Determine-If-Your-System-969670e3

Option Explicit 
Dim ObjWMI, ColSettings, ObjProcessor 
Dim StrComputer, ObjNetwork 
Set ObjNetwork = WScript.CreateObject("WScript.Network") 
StrComputer = Trim(ObjNetwork.ComputerName) 
Set ObjNetwork = Nothing 
WScript.Echo VbCrLf & "Computer Name: " & StrComputer 
WScript.Echo vbNullString 
Set ObjWMI = GetObject("WINMGMTS:" & "{ImpersonationLevel=Impersonate,AuthenticationLevel=Pkt}!\\" & StrComputer & "\Root\CIMV2") 
Set ColSettings = ObjWMI.ExecQuery ("SELECT * FROM Win32_Processor") 
For Each ObjProcessor In ColSettings 
Select Case ObjProcessor.Architecture 
    Case 0 
        WScript.Echo "Processor Architecture Used by the Platform: x86" 
    Case 6 
        WScript.Echo "Processor Architecture Used by the Platform: Itanium-Based System" 
    Case 9 
        WScript.Echo "Processor Architecture Used by the Platform: x64" 
End Select 
Select Case ObjProcessor.ProcessorType 
    Case 1 
        WScript.Echo "Processor Type: Other. Not in the Known List"     
    Case 2 
        WScript.Echo "Processor Type: Unknown Type" 
    Case 3 
        WScript.Echo "Processor Type: Central Processor (CPU)" 
    Case 4 
        WScript.Echo "Processor Type: Math Processor" 
    Case 5 
        WScript.Echo "Processor Type: DSP Processor" 
    Case 6 
        WScript.Echo "Processor Type: Video Processor" 
End Select 
WScript.Echo "Processor: " & ObjProcessor.DataWidth & "-Bit" 
WScript.Echo "Operating System: " & ObjProcessor.AddressWidth & "-Bit" 
WScript.Echo vbNullString     
If ObjProcessor.Architecture = 0 AND ObjProcessor.AddressWidth = 32 Then 
    WScript.Echo "This Machine has 32 Bit Processor and Running 32 Bit OS" 
End If 
If (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 32 Then 
    WScript.Echo "This Machine has 64-Bit Processor and Running 32-Bit OS" 
End If 
If (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 64 Then 
    WScript.Echo "This Machine has 64-Bit Processor and Running 64-Bit OS" 
End If 
Next 
Set ObjProcessor = Nothing:    Set ColSettings = Nothing:    Set ObjWMI = Nothing:    StrComputer = vbNullstring
于 2014-12-25T14:40:43.153 に答える
1

あなたは簡単だと言いましたが、言語を指定しませんでした...

バッチ ( .cmd):

IF /I %PROCESSOR_ARCHITECTURE% EQU x86 (
    msiexec /qn /i 7zip_x86.msi
) ELSE (
    msiexec /qn /i 7zip_x64.msi
)

VB スクリプト ( .vbs):

Set oShell = WScript.CreateObject("WScript.Shell")
proc_arch = oShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")

If proc_arch = 'x86' Then
    oShell.Run("msiexec /qn /i 7zip_x86.msi"), 0, true 
Else
    oShell.Run("msiexec /qn /i 7zip_x64.msi"), 0, true
End If

PowerShell ( .ps1):

if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
    & msiexec /qn /i 7zip_x86.msi
} else {
    & msiexec /qn /i 7zip_x64.msi
}
# or ...
if ([Environment]::Is64BitOperatingSystem) {
    & msiexec /qn /i 7zip_x86.msi
} else {
    & msiexec /qn /i 7zip_x64.msi
}
于 2013-02-26T20:22:58.600 に答える