What is wrong with this command line?


  1. Posts : 20
    Windows7 32bit
       #1

    What is wrong with this command line?


    Help please I am pulling my hair out.

    I use a desktop shortcut to run an application called get_iplayer.cmd located in the directory c:\program files\get_iplayer

    The line in the Target of the shortcut properties therefore reads:

    C:\Windows\System32\cmd.exe /k "c:\program files\get_iplayer\get_iplayer.cmd"

    When the shortcut is run (as administrator) the following lines are returned:

    'c:\program' is not a recognized internal or external command, operable program or batch file
    c:\windows\system32>


    However if I repeat the command again by running cmd and use CD to get to manually change directories the program runs as expected.

    What is going wrong?
      My Computer


  2. Posts : 5,092
    Windows 7 32 bit
       #2

    This is the dreaded space in the filename issue. When you run a command with spaces in the path you must double up the double quotes as shown in the example
    "Spaces in Program Path:"
    CMD.exe (Command Shell) | Windows CMD | SS64.com
      My Computer


  3. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #3

    Try:
    C:\Windows\System32\cmd.exe /k ""c:\program files\get_iplayer\get_iplayer.cmd""
      My Computer


  4. Posts : 20
    Windows7 32bit
    Thread Starter
       #4

    Sorry but I just get a label syntax error with the double ""
      My Computer


  5. Posts : 20
    Windows7 32bit
    Thread Starter
       #5

    actually i was wrong i now get

    ' "c:\program files\get_iplayer\get_iplayer.cmd' " is not recognised as an internal or external command ...blaa.. blaa..
      My Computer


  6. Posts : 5,092
    Windows 7 32 bit
       #6

    How about let the shell do it? Right click in the folder where the .cmd file is, New Shortcut, choose the .cmd file as target. Then if it works you should be able to drag the shortcut to the desktop or wherever and have it still function.

    Edit: Or do it another way. Right click your shortcut on the desktop and click Properties. Fill in the "Start in:" field with the folder where the .cmd file is. Since program files has a space you may need to wrap it in double quotes. But this method should be more reliable.
      My Computer


  7. Posts : 6,458
    x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
       #7

    Use the environment variable, ProgramFiles

    C:\Windows\System32\cmd.exe /k %ProgramFiles%\get_iplayer\get_iplayer.cmd
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:26.
Find Us