批处理文件以检查os体系结构,然后执行适当的exe [英] Batch file to check os architecture and then execute appropriate exe

查看:77
本文介绍了批处理文件以检查os体系结构,然后执行适当的exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个批处理文件,以简化为用户安装驱动程序的过程。

I am trying to write a batch file which will ease the process of installing drivers for our users.

该批处理文件需要检查os(64位)的版本或32位)代码正在运行,然后执行相应的 .exe

The batch file needs to check what version of os (64bit or 32bit) the code is running on and then execute the appropriate .exe.

远:

set os_version=wmic os get osarchitecture
echo "%os_version%"
pause

IF os_version = "64-bit"
@run 64 bit
start /d "%0" CP210xVCPInstaller_x64.exe
ELSE
@run 32 bit
start /d  "%0" CP210xVCPInstaller_x86.exe

现在我在分配时遇到问题命令 wmic os get osarchitecture 的输出到变量。

Now I am having an issue with assigning the output of the command wmic os get osarchitecture to a variable.

然后我需要检查它是否相等到 64位,如果是的话,在与bat文件相同的位置执行 .exe 吗?

Then I need to check if it is equal to 64-bit and if so execute a .exe in the same location as the bat file?

第二个问题是如何从与bat fi相同的目录中运行 .exe le?

Second Question is how do I run a .exe from the same directory as the bat file?

推荐答案

这很简单:

if exist "%SYSTEMDRIVE%\Program Files (x86)\" (
   start "" /d "%~dp0" "CP210xVCPInstaller_x64.exe"
) else (
   start "" /d "%~dp0" "CP210xVCPInstaller_x86.exe"
)

这篇关于批处理文件以检查os体系结构,然后执行适当的exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆