场景:
Linux的alias命令是个非常实用的工具,任何命令通过alias可以精简到很短,比如:alias l='ls -l'
Windows也有alias类似的命令,就是:doskey,开启方法也很简单
环境:win7 + 64 bit
1. C:\Users[用户名]\alias_key.bat
@doskey ls=dir /b $* @doskey l=dir /od/p/q/tw $* @REM notepad++工具设置别名为:npp @doskey npp="C:\Program Files1\Notepad++\notepad++.exe" $* @doskey p=python $* @doskey py=python $*
- 等号左边是右边的别名
- $*表示这个命令还可能有其他参数
- @表示执行这条命令时不显示这条命令本身
2. alias_key.reg
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Command Processor] "AutoRun"="%USERPROFILE%\\alias_key.bat"
双击上述 aliaskey.reg 文件,导入到注册表!
3. 打开cmd,然后运行:ls 或 npp 命令,看看效果
参考:
https://superuser.com/questions/49170/create-an-alias-in-windows-xp Create an alias in Windows XP
https://www.awaimai.com/2445.html
http://www.cnblogs.com/fstang/archive/2013/04/06/3002006.html
延伸:
%USERPROFILE% =C:\Users\用户名 %SystemRoot% =C:\WINDOWS %SystemDrive% =C: %APPDATA% =C:\Users\用户名\AppData\Roaming %LOCALAPPDATA% =C:\Users\用户名\AppData\Local %windir% =C:\WINDOWS %Path% =C:\Windows\system32;C:\Windows; %ProgramData% =C:\ProgramData %ProgramFiles% =C:\Program Files %ProgramFiles(x86)% =C:\Program Files (x86)
其他:
%ALLUSERSPROFILE% =C:\ProgramData %CommonProgramFiles% =C:\Program Files\Common Files %CommonProgramFiles(x86)% =C:\Program Files (x86)\Common Files %CommonProgramW6432% =C:\Program Files\Common Files %COMPUTERNAME% =MyPC %ComSpec% =C:\WINDOWS\system32\cmd.exe %HOMEDRIVE% =C: %HOMEPATH% =\Users\用户名 %LOGONSERVER% =\\MicrosoftAccount %OS% =Windows_NT %ProgramW6432% =C:\Program Files %PUBLIC% =C:\Users\Public %TEMP% =C:\Users\用户名\AppData\Local\Temp %TMP% =C:\Users\用户名\AppData\Local\Temp %USERDOMAIN% =MyPC %USERNAME% =用户名
转载自:https://www.cnblogs.com/onelikeone/p/10783497.html
来源:https://www.cnblogs.com/chenjo/p/12550207.html