How to lunch command line with arguments on windows using shortcut

in #coding7 years ago (edited)

Shortcut Icon to Lunch Command line with arguments on windows

I spent some time learning how to create a shortcut icon that will open windows command prompt and pass arguments.

I needed to do the following;

  • Open command prompt
  • Lunch web browser to open local host on specific port
  • Change directory
  • Pass arguments to start a server
  • Create shortcut on desktop

Here is the final code

First create a file with named with .bat extension (for example name.dat)

@ECHO OFF
start "" http://localhost:2000 & CD C:\home\server\ && npm start
exit

Notice & and && was used. When I used & each of the commands would run independent of the other.

Right click on the bat file (name.bat) and create a shortcut icon on desktop.

To further customize the shortcut icon, right click on the shortcut icon, go to properties there you can add display icon, run command line minimized or lunch command line with admin privilege.

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.029
BTC 65560.09
ETH 3467.72
USDT 1.00
SBD 2.68