Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如果操作系统是64位的_Batch File_Command Line_Vbscript - Fatal编程技术网

Batch file 如果操作系统是64位的

Batch file 如果操作系统是64位的,batch-file,command-line,vbscript,Batch File,Command Line,Vbscript,我试图写入一个文件,我有一个if语句来检测用户使用的是64位还是32位操作系统。我试过这个 write.bat (它在appdata文件夹中生成vbs文件) 这很好用。然而,当它要写一个文件时,它奇怪地试图同时写这两个文件 if defined ProgramFiles(x86) ( find "lnk.targetpath = ""C:\Program Files (x86)\Google\Chrome\Application\chrome.exe""" %APPDATA%\System.v

我试图写入一个文件,我有一个if语句来检测用户使用的是64位还是32位操作系统。我试过这个

write.bat (它在appdata文件夹中生成vbs文件)

这很好用。然而,当它要写一个文件时,它奇怪地试图同时写这两个文件

if defined ProgramFiles(x86) (

find "lnk.targetpath = ""C:\Program Files (x86)\Google\Chrome\Application\chrome.exe""" %APPDATA%\System.vbs || echo lnk.targetpath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe">>%APPDATA%\System.vbs

    ) else (

find "lnk.targetpath = ""C:\Program Files\Google\Chrome\Application\chrome.exe""" %APPDATA%\System.vbs || echo lnk.targetpath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe">>%APPDATA%\System.vbs

    )

如何解决此问题?

尝试使用此vbscript检查用户使用的是64位还是32位操作系统

'un vbscript qui détermine automatiquement le type de votre système d'exploitation
Copyright = " © Hackoo © 2014"
MsgFr = "Le type de votre système d'exploitation " 
MsgAr = ChrW(1606)&ChrW(1608)&ChrW(1593)&ChrW(32)&ChrW(1606)&ChrW(1592)&ChrW(1575)&ChrW(1605)&ChrW(32)&_
ChrW(1575)&ChrW(1604)&ChrW(1578)&ChrW(1588)&ChrW(1594)&ChrW(1610)&ChrW(1604)&ChrW(32)&ChrW(1575)&ChrW(1604)&_
ChrW(1582)&ChrW(1575)&ChrW(1589)&ChrW(32)&ChrW(1576)&ChrW(1603)
If Is64Bit = False then
    MsgBox MsgFr & MsgAr & VbCrLF & "32 bits" ,Vbinformation,MsgFr & MsgAr & Copyright
else
    Msgbox MsgFr & MsgAr & VbCrLF & "64 bits",Vbinformation,MsgFr & MsgAr & Copyright
End if
'**************************************************************************************************************
Function Is64Bit() 
    Is64Bit = False 
    Dim colOS : Set colOS = GetObject("WinMGMTS://").ExecQuery("SELECT AddressWidth FROM Win32_Processor",, 48) 
    Dim objOS 
    For Each objOS In colOS 
        If objOS.AddressWidth = 64 Then Is64Bit = True 
    Next 
End Function
'***************************************************************************************************************
在批处理中,您可以进行如下尝试:

@echo off
wmic cpu get addresswidth | find "32" >nul  && echo systeme 32 bit || echo systeme 64 bit
pause

else
子句的
echo
部分中的值错误。在这两种情况下,您重复了相同的值。
@echo off
wmic cpu get addresswidth | find "32" >nul  && echo systeme 32 bit || echo systeme 64 bit
pause