简体   繁体   中英

pwd alias on Windows cmd

I want to create a fixed pwd alias like in this topic, but I want to keep all aliases in one file as in this answer by Argyll. Currently my file cmdAliases.cmd looks like this:

@echo off

doskey ls=dir
doskey pwd=echo ^%cd^%

Running pwd command now prints:

ECHO is on.

I believe the spaces in the command are the problem. Is there a way to fix it using only the cmdAliases.cmd file?

The links you provided show how to do it.

I have my doskey macros in a file aliases.txt in my folder %USERPROFILE%

11:24:16 C:\Users\LotPings________________________________________
> type Aliases.txt
~=CD /D "C:\Users\LotPings"
\=CD \
-=CD ..
Alias=Doskey $*
Aliases=Doskey /MACROS:ALL

And an autorun entry which loads this file

> reg query "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v autorun
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
    autorun    REG_SZ    Doskey /MacroFile="C:\Users\LotPings\Aliases.txt"

To generate this Autorun automatically copy the following lines into cmd line or a batch file

Set "Key=HKEY_CURRENT_USER\Software\Microsoft\Command Processor"
Set "Val=Autorun"
Set "Typ=REG_SZ"
Set "Dat=Doskey /Macrofile=\"%USERPROFILE%\Aliases.txt\""
reg add "%Key%" /v %Val% /t %Typ% /d "%Dat%" /f

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM