2012-07-02 2 views
0

방금 ​​7zip (x86 및 x64) 용 .msi 설치 관리자를 다운로드했습니다. 누구든지 OS 구조를 감지하고 적절한 .msi 파일을 시작하는 데 사용할 수있는 간단한 스크립트가 있습니까? OS 아키텍처 검색 스크립트

그냥 64 비트 시스템에만 존재 C:\Program Files (x86)의 존재를 확인 ...

답변

0

아마 원유 매우 ... "안전"없습니다. 이 도움이 될

0

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 
0

당신은 간단하게 말했지만 언어를 지정하지 않은 ...

배치 (CMD) :

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

VBScript를 (.VBS) :

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

위대한 vbscrip t, Monimoy Sanyal이 작성, Microsoft Technet에 게시 됨. 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