1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

strange error in alias

Discussion in 'Support' started by aria1946, Nov 21, 2011.

Thread Status:
Not open for further replies.
  1. aria1946

    Joined:
    Aug 31, 2011
    Messages:
    5
    Likes Received:
    0
    OS: Vista Home Premium 64bit

    C:\Windows\System32]alias kill 'c:\windows\system32\taskkill.exe /im %1 /t /f'

    [C:\Windows\System32]kill
    TCC: Unknown command "'c:\windows\system32\taskkill.exe"

    taskkill is a Vista command, and when I try to create an alias called "kill" to invoke the command, I get the above error. I can type "taskkill" at the command prompt and I get the usual info about the command, but when I try to use the alias it's as if the taskkill command isn't found
     
  2. TEA-Time

    Joined:
    Jun 2, 2008
    Messages:
    282
    Likes Received:
    1
    I think what you're seeing is the result of the redirection in 64bit Windows. See Rex's response in this thread:

    http://jpsoft.com/forums/support/3373-different-results-between-tcmd-cmd.html
     
  3. aria1946

    Joined:
    Aug 31, 2011
    Messages:
    5
    Likes Received:
    0
    Sorry, I guess I should have stated that I am running TCMD 64-bit.

    Interestingly, if I put the same text into a btm file, it works fine. It seems that only the alias won't work.

    Tom
     
  4. TEA-Time

    Joined:
    Jun 2, 2008
    Messages:
    282
    Likes Received:
    1
    Oh.. it's the single quotes you have around everything. Remove them and it should work fine.
     
  5. aria1946

    Joined:
    Aug 31, 2011
    Messages:
    5
    Likes Received:
    0
    [C:\Program Files\JPSoft\TCMD13x64]alias kill taskkill.exe /im %1 /t /f

    [C:\Program Files\JPSoft\TCMD13x64]kill deskpins.exe
    ERROR: Invalid syntax. Value expected for '/im'.
    Type "TASKKILL /?" for usage.
     
  6. TEA-Time

    Joined:
    Jun 2, 2008
    Messages:
    282
    Likes Received:
    1
    Ok, you've got it running. :) But when you pass it the /im switch, it expects it to be followed by a value. Even without being in a alias, taskkill /im will give you the same error. It's when you run it without any parameters that it spits out the help.
     
  7. aria1946

    Joined:
    Aug 31, 2011
    Messages:
    5
    Likes Received:
    0
    The strange thing is, the %1 that I define into the alias is not stored. If I print out the alias the %1 is gone, so how do I pass a parameter to an alias on the command line?

    I want to "kill deskpins.exe" but when I type it as a command, the alias doesn't contain the %1 so there's no place for the parameter to get passed.

    [C:\Program Files\JPSoft\TCMD13x64]alias kill taskkill /im %1 /t /f

    [C:\Program Files\JPSoft\TCMD13x64]alias kill
    taskkill /im /t /f

    notice the missing %1
     
  8. TEA-Time

    Joined:
    Jun 2, 2008
    Messages:
    282
    Likes Received:
    1
    Ah.. ok, that helps me understand what else I missed. Double up the percent like so:

    alias kill c:\windows\system32\taskkill.exe /im %%1 /t /f
     
  9. dbartt

    Joined:
    May 29, 2008
    Messages:
    36
    Likes Received:
    0
    You need to surround the alias with back quotes when you create it so that no
    expansion or substitution is done until the alias is run:

    alias kill `c:\windows\system32\taskkill.exe /im %1 /t /f`
     
  10. aria1946

    Joined:
    Aug 31, 2011
    Messages:
    5
    Likes Received:
    0
    Thank you! Problem solved!

    Tom
     
Thread Status:
Not open for further replies.

Share This Page