|
本帖最后由 lintrainwy 于 2020-2-28 00:27 编辑
- @ECHO OFF
- setlocal ENABLEDELAYEDEXPANSION
- mode con cols=80 lines=25
- color 0a
- :: 批处理获取管理员权限
- :-------------------------------------
- %1 mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&&exit /b
- pushd "%CD%"& CD /D "%~dp0"
- :--------------------------------------
- cd /d "%~dp0"
- echo 导入运行库DLL
- pushd "%~dp0"
- if defined programw6432 (
- if %PROCESSOR_ARCHITECTURE%==AMD64 (
- echo 64bit/64bit OS
- copy /y ".\dll\32bit\*" "%Windir%\SysWOW64">nul 2>&1
- copy /y ".\dll\64bit\*" "%Windir%\System32">nul 2>&1
- ) else (
- echo 32bit/64bit OS
- copy /y ".\dll\32bit\*" "%Windir%\System32">nul 2>&1
- copy /y ".\dll\64bit\*" "%Windir%\Sysnative">nul 2>&1
- )
- ) else (
- echo 32bit/32os
- copy /y ".\dll\32bit\*" "%Windir%\System32">nul 2>&1>nul 2>&1
- )
- popd
- pause
- goto :EOF
复制代码
说明 %windir%\System32 %windir%\SysWOW64 %windir%\Sysnative
%windir%\Sysnative 为重定向访问路径
32bit OS 64bit OS
32bit exe System32 System32/SysWOW64/Sysnative
64bit exe - System32/SysWOW64
32bit OS not defined ProgramW6432
64bit OS defined ProgramW6432
32bit exe %PROCESSOR_ARCHITECTURE%==x86
64bit exe %PROCESSOR_ARCHITECTURE%==AMD64
____________________________________
rem 判断64/32位系统,四种方法
::set "OSbit=32" &wmic os get OSArchitecture|find "64">nul 2>&1 && set "OSbit=64"
::set "OSbit=32" ® query "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE|find "64">nul 2>&1 &&set "OSbit=64"
::if EXIST %windir%\SysWOW64 (set "OSbit=64")else (set "OSbit=32")
set "OSbit=32" &if defined programw6432 set "OSbit=64"
rem 判断64/32位程序
set "exebit=32" &echo %processor_architecture% |find "64">nul 2>&1 && set "exebit=64"
echo %exebit% 位程序运行在 %OSbit% 位操作系统上
pause
|
|