Create shortcut for complex commands in CMD

1

I use the taskkill /f /im nome.exe command to stop processes, because the same for all processes with the same name.

  

I would like to commit this command to something like tk nome.exe .

I tried to create an environment variable, it even worked, but I have to type this way:

%tk% nome.exe

How can I create this command shortcut?

    
asked by anonymous 09.04.2018 / 20:27

2 answers

5

I'll give you a very simple example, which will not depend on any external program:

  • Create a folder in a specific place, for example C:\meus_comandos
  • Go to the Computer and right-click (mouse) and then select properties:

  • ClickAdvancedSystemSettings:

  • Clickonenvironmentvariables

  • SelectPATHandclickEdit...

  • ClickNew:

  • The option to type will be released, then type:

    C:\meus_comandos
    

    Creating the commands:

    Now in the folder meus_comandos you can create as many .bat files as you want and they will be recognized as commands, create a file named tk.bat in the folder and add this content:

    @echo off
    
    taskkill /f /im %1
    

    Then open the cmd in any folder and enter this:

    tk nome.exe
    
        
    09.04.2018 / 23:33
    1

    You can create an alias for your command using DOSKEY

    Just create a file in any directory, for example:

    C: \ Users \ TomMelo \ Documents \ macros.doskey

    print=echo $*
    

    Then just add a one regkey to make the alias available every time you are using cmd:

    reg add "HKCU\Software\Microsoft\Command Processor" /v Autorun /d "doskey /macrofile=\"C:\Users\TomMelo\Documents\macros.doskey\"" /f
    

    Close the cmd and open a new session, your alias should already be available. For more options on parameters take a look at here too.

        
    09.04.2018 / 23:10