我可以创建一个批处理文件来运行这样的应用程序:
python manage.py ping_google [/sitemap.xml]
但是由于客户端工作站的操作系统是32位操作系统(我的是64位操作系统),我如何编写一个可以在我的工作站和客户端上运行的命令?
答案 0 :(得分:1)
:CheckOS
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)
:64BIT
START "" "C:\Program Files (x86)\Folder\myapp.exe"
GOTO END
:32BIT
START "" "C:\Program Files\Folder\myapp.exe"
GOTO END
:END
答案 1 :(得分:0)
我建议使用批处理代码,它首先会在启动之前首先搜索应用程序。
@echo off
rem The program files folder exists on all Windows.
for /R "%ProgramFiles%" %%I in (myapp*.exe) do (
start "" "%%I"
goto :EOF
)
rem The x86 program files folder exists only on all Windows x64.
if not "%ProgramFiles(x86)%" == "" (
for /R "%ProgramFiles(x86)%" %%I in (myapp*.exe) do (
start "" "%%I"
goto :EOF
)
)
echo Can't find myapp.exe in any program files folder.
echo.
pause
但是如果安装应用程序时添加了可执行文件名作为
的键HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths
或
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths
命令 start 会在仅指定myapp.exe
时找到自行启动的应用程序。有关详细信息,请参阅Where is “START” searching for executables?和How to enumerate all programs that can open XML file as plain text?上的答案。
答案 2 :(得分:-1)
尝试检查目录是否存在,如下所示:
@ECHO OFF
IF EXIST "%PROGRAMFILES(X86)%" (
START "" "C:\Program Files (x86)\Folder\myapp.exe"
) ELSE (
START "" "C:\Program Files\Folder\myapp.exe"
)