Lou*_*hys 25 windows path environment-variables
例如,我想将 notepad++ 添加到我的 PATH,但是该目录还包含uninstall.exe和其他几个文件/可执行文件,我不希望它们“污染”我的路径。我可以只添加一个notepad++.exe吗?
par*_*oid 18
您可以将批处理脚本添加到路径中的目录中,如下所示:
@echo off
:: Notepad++ execution
if [%1]==[-h] goto :HELP
if [%1]==[--help] goto :HELP
if [%1]==[/?] goto :HELP
goto :START
:START
start "" /i "%ProgramFiles(x86)%\notepad++\notepad++.exe" %*
goto :EOF
:HELP
echo -------------------------------
echo Notepad++ Command Argument Help
echo -------------------------------
echo Usage :
echo.
echo notepad++ [--help] [-multiInst] [-noPlugins] [-lLanguage] [-nLineNumber] [-cColumnNumber] [-xPos] [-yPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [fullFilePathName]
echo.
echo --help : This help message
echo -multiInst : Launch another Notepad++ instance
echo -noPlugins : Launch Notepad++ without loading any plugin
echo -l : Launch Notepad++ by applying indicated language to the file to open
echo -n : Launch Notepad++ by scrolling indicated line on the file to open
echo -c : Launch Notepad++ on scrolling indicated column on the file to open
echo -x : Launch Notepad++ by indicating its left side position on the screen
echo -y : Launch Notepad++ by indicating its top position on the screen
echo -nosession : Launch Notepad++ without any session
echo -notabbar : Launch Notepad++ without tabbar
echo -ro : Launch Notepad++ and make the file to open read only
echo -systemtray : Launch Notepad++ directly in system tray
echo -loadingTime : Display Notepad++ loading time
echo -alwaysOnTop : Make Notepad++ always on top
echo fullFilePathName : file name to open (absolute or relative path name)
echo.
goto :EOF
:EOF
Run Code Online (Sandbox Code Playgroud)
你可以命名它notepad++.cmd。帮助部分可让您轻松获取有关开关的信息。
我将所有此类脚本和命令行程序放在一个目录中,该目录添加到%PATH%:
C:\Users\Public\Command\
...并且该目录同步到所有计算机和虚拟机。
Mat*_*ner 14
创建一个包含如下内容的批处理文件:
@"C:\Program Files\Git\bin\git.exe" %*
Run Code Online (Sandbox Code Playgroud)
这应该保存为.bat文件,例如保存git.bat在PATH.
@抑制将命令回显到调用 shell。引号""可防止将空格解释为参数分隔符。%*将任何参数粘贴到批处理文件中,改为粘贴到引用的可执行文件中。
您现在可以使用批处理文件名之前的部分调用可执行文件.bat。就我而言,git.
参考: