代码之家  ›  专栏  ›  技术社区  ›  Bobby B

运行方式的别名DOS命令

  •  5
  • Bobby B  · 技术社区  · 16 年前

    具体地说,我厌倦了获得投标的完整途径( "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" ssms .

    有人知道怎么做吗?我知道我可以用批处理文件来完成,但我真的不想。

    runas /user:user /netonly bids
    

    与。

    runas /user:user /netonly "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
    
    3 回复  |  直到 16 年前
        1
  •  2
  •   Community Mohan Dere    9 年前

    这个 doskey 这项技术在SuperUser上有介绍,请参阅 https://superuser.com/questions/49170/create-an-alias-in-windows-xp .

    runas . 您可以定义一个包含这两者的别名 符文 您希望运行的命令,但这将不可重用。但是这样做怎么样:

    SET BIDS=C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
    DOSKEY r=runas /user:user /netonly "%$1%"
    

    然后你可以像这样使用

    r bids
    

    当然,这需要为您想要的每个快捷方式设置一个环境变量,但我认为这并不比设置 多斯凯 别名本身。在任何情况下,它都不会创建文件,也不需要在 path .

    我自己没有试过,但看起来你完全可以把它设置好然后忘记。

    • 可以通过Windows的系统设置来设置环境变量(参见图)
    • DOSKEY 每次都可以设置别名 cmd.exe 开始 using the registry

    enter image description here

        2
  •  1
  •   Basic    15 年前

    我认为您遇到的问题是,命令行被评估为新用户—因此,除非新用户也可以访问您的别名,否则它将无法工作。

    编辑:

    看到了吗 here here 有关choice命令的信息

    示例用法:

    @ECHO OFF
    Echo 1. Some Command
    Echo 2. Some Other Command
    CHOICE /C:12 /N /T:1,10 Choose an option
    IF ERRORLEVEL 2 GOTO COMMAND2
    IF ERRORLEVEL 1 GOTO COMMAND1
    GOTO END
    
    :COMMAND1
    Runas /Uer:Blah "BLAH" > NUL
    GOTO END
    
    :COMMAND2
    Runas /Uer:Blah "BLAH" > NUL
    GOTO END
    
    :END
    
        3
  •  1
  •   djangofan    13 年前

    下面是一个脚本,它将在您的命令shell上设置别名。此脚本提供了难以捉摸的“WHERE”命令:

    @ECHO OFF 
    ECHO Loading additional commands from:
    ECHO    %0
    ECHO Type 'DOSKEY /MACROS:ALL' to see the configured commands.
    :: to install, place this .bat script in the location you want 
    :: it to reside and then run this batch script with the argument "register"
    IF "%1"=="register" (
      REG.exe ADD "HKCU\Software\Microsoft\Command Processor\Autorun" /ve /t REG_SZ /d "%0" /f
      ECHO The DOS profile is registered.  Load a new command prompt and test a command.
    )
    @DOSKEY LS=DIR /w 
    @DOSKEY CP=COPY $* 
    @DOSKEY MV=MOVE $* 
    @DOSKEY H=DOSKEY /HISTORY
    @DOSKEY WHERE=@for %%e in (%PATHEXT%) do @for %%i in ($*%%e) do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i
    
    推荐文章