0

I open cmd and write cd Desktop\PES and then I write again pes.exe to run the pes.exe file. Now, I want to ask if the above two commands can be written as one in the cmd and how can I create a shortcut (right click -> New -> Shortcut) in order to run the above code?

darkchampionz
  • 1,174
  • 5
  • 24
  • 47
  • 1
    The properties of a shortcut have the edit field __Start in__ which makes the usage of command `cd /D "%USERPROFILE%\Desktop\PES"` useless as this is done by Windows before starting the application. Specify "%USERPROFILE%\Desktop\PES" for __Start in__ in shortcut properties and specify as command to execute the file `pes.exe` with full path, i.e. `"%USERPROFILE%\Desktop\PES\pes.exe"`. – Mofi Apr 10 '17 at 16:47
  • [Single line with multiple commands using Windows batch file](http://stackoverflow.com/questions/25343351/) answers also your question. The ampersand makes it possible to run multiple commands from single line. The command line for the shortcut properties would be `%SystemRoot%\System32\cmd.exe /C cd /D "%USERPROFILE%\Desktop\PES" & pes.exe`. But this solution is suboptimal, especially if `pes.exe` is a GUI application and therefore running a command process with a console window just for executing the GUI application is definitely not good. – Mofi Apr 10 '17 at 16:58

2 Answers2

1

Have you considered a batch script? Write those commands into notepad and save with .bat extension. Can run as one command in cmd and, though wouldn't be technically a shortcut, could be saved to desktop.

plantbeard
  • 358
  • 7
  • 16
0

You can add the following command in your shortcuts.xml file. (In <UserDefinedCommands></UserDefinedCommands> section)

<Command name="Run in CMD" Ctrl="yes" Alt="no" Shift="yes" Key="67">&quot;cmd.exe&quot; /K &quot;cd, c:\users&quot; & notepad</Command>

Essentially NPP is sending the following command. (& is used to enter multiple commands.)

cmd.exe /K "c:\users" & Notepad

The above command adds a shortcut in Run menu called 'Run in CMD'.

  1. The command opens the command prompt
  2. Changes the directory to c:\users.
  3. Open a Notepad.

Note:

  • Do not change the shortcuts.xml in Notepad++, it may not save the changes. Rather use Notepad or other text editor to make those changes.
  • You can also assign a keyboard shortcut to this command using Shortcut Mapper.
NotepadPlusPlus PRO
  • 987
  • 1
  • 8
  • 21