How to lunch command line with arguments on windows using shortcut

in coding •  8 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.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!