Hi, I have a folder full of files, and I'm looking for a way to automate the following:
Through a shortcut or Batch file;
Open the command prompt at a specific location, so the command prompt is ready to execute commands in that directory (the same as "Open Command Window here"), with arguments ready to execute when the file or shortcut opens. However I've ran into problems getting this to work. I have this in my shortcut:
C:WindowsSystem32cmd.exe /k "cd C:UserslewisDesktopMainDir" C:Python27python.exe example.py -a ptc -u _____ -p _____ -l "__ __, _" -st 10"
Note that the "_" are replaced with letters/numbers on my screen.
In this case, the command prompt window opens, but I get a "The filename, directory name, or volume label syntax is incorrect." error.
However if I do it this way, it works:
Go to "C:UserslewisDesktopMainDir" --> Shift+Right-click --> "Open Command Window here" --> Paste in this Dir:
C:Python27python.exe example.py -a ptc -u _____ -p _____ -l "__ __, _" -st 10"
So, How can I get it to automate instead of me having to do it manually, and why does it function differently when I do it manually?
The /kswitch for cmd.exeneeds a path as a parameter, not a command.
You have now a CD command as a parameter:Code:C:WindowsSystem32cmd.exe /k "cdC:UserslewisDesktopMainDir"
It should be just a path:Code:C:WindowsSystem32cmd.exe /k "C:UserslewisDesktopMainDir"
EDIT:
No, that's not it! Was looking the error in wrong place.
Kari
I fixed it but I still get the same error. Could it be because I'm using "C:UserslewisDesktopMainDir" after already using a Directory?
The command to open Command Promp should be alone on its own command line. Try to separate them, put the Python command in next line in your batch file:Code:C:WindowsSystem32cmd.exe /k "cd C:UserslewisDesktopMainDir" C:Python27python.exe example.py -a ptc -u _____ -p _____ -l "__ __, _" -st 10"
Thanks, I fixed it