1

我正在尝试创建一个登录批处理文件以将 32 位和 64 位可执行文件从服务器复制到用户的本地计算机,然后根据操作系统类型/架构执行这些文件。这是我到目前为止所拥有的,它似乎没有工作,因为它只启动 32 位文件并且没有检测和启动 64 位文件。我是新手,因此将不胜感激。

@echo off
c:
MD c:\temp
xcopy \\server\NETLOGON\SEPRemoval c:\temp /e /y
cd c:\temp
if /i "%PROCESSOR_ARCHITECTURE%" EQU "x86" goto ARCH32
if /i "%PROCESSOR_ARCHITECTURE%" EQU "AMD64" goto ARCH64


:ARCH32
start /wait SEPprep.exe
goto done

:ARCH64
start /wait SEPprep64.exe
goto done

:done

timeout 15
cd \
del c:\temp /q
exit
4

3 回答 3

0

This is what I finally came up with that works with assistance from some guys over at the Microsoft Scripting Guys forum:

@echo off
c:
MD c:\temp
xcopy \\server\NETLOGON\SEPRemoval c:\temp\ /e /y
cd /d c:\temp
if {%PROCESSOR_ARCHITEW6432%} EQU {} (
  set TRUE_ARCH=%PROCESSOR_ARCHITECTURE%
   start /b /wait SEPprep.exe
   goto Done
) else (
  set TRUE_ARCH=%PROCESSOR_ARCHITEW6432%
  start /b /wait SEPprep64.exe
  goto Done
)
echo Processor Architecture is %PROCESSOR_ARCHITECTURE%

:Done
timeout 15
rd /s /q c:\temp 1>nul 2>nul
exit
于 2013-02-01T19:40:22.327 回答
0

查看systeminfo

%SystemRoot%\system32\systeminfo.exe

或者像这样简单的东西

if defined ProgramFiles(x86)

这将检查是否定义了 ProgramFiles(x86) 环境变量(仅在 64 位版本的 Windows 上定义)。

于 2013-02-01T02:37:35.803 回答
0

The problem isn't your batch file, it's that you're relying on an environment variable that doesn't do what you think it does.

On my 64-bit Windows 7 machine, ENV shows:

PROCESSOR_ARCHITECTURE=x86
PROCESSOR_ARCHITEW6432=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=6

...so relying on PROCESSOR_ARCHITECTURE to differentiate between 32 & 64 bit machines isn't going to work.

There is a Microsoft Knowledge Base article on the topic.

Fix your method of detecting processor architecture, and you should be OK.

于 2013-01-31T21:54:36.307 回答