How do I execute cmd commands through a batch file?

前端 未结 8 758
难免孤独
难免孤独 2020-12-02 07:37

I want to write a batch file that will do following things in given order:

  1. Open cmd
  2. Run cmd command cd c:\\Program files\\IIS Express
相关标签:
8条回答
  • 2020-12-02 07:51

    This fixes some issues with Blorgbeard's answer (but is untested):

    @echo off
    cd /d "c:\Program files\IIS Express"
    start "" iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0
    timeout 10
    start http://localhost:8088/default.aspx
    pause
    
    0 讨论(0)
  • 2020-12-02 08:01

    So, make an actual batch file: open up notepad, type the commands you want to run, and save as a .bat file. Then double click the .bat file to run it.

    Try something like this for a start:

    c:\
    cd c:\Program files\IIS Express
    start iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0
    start http://localhost:8088/default.aspx
    pause
    
    0 讨论(0)
  • 2020-12-02 08:08

    cmd /k cd c:\ is the right answer

    0 讨论(0)
  • 2020-12-02 08:09
    start cmd /k "your cmd command1"
    start cmd /k "your cmd command2"
    

    It works in Windows server2012 while I use these command in one batch file.

    0 讨论(0)
  • 2020-12-02 08:11

    cmd /c "command" syntax works well. Also, if you want to include an executable that contains a space in the path, you will need two sets of quotes.

    cmd /c ""path to executable""
    

    and if your executable needs a file input with a space in the path a another set

    cmd /c ""path to executable" -f "path to file"" 
    
    0 讨论(0)
  • 2020-12-02 08:11

    I know DOS and cmd prompt DOES NOT LIKE spaces in folder names. Your code starts with

    cd c:\Program files\IIS Express

    and it's trying to go to c:\Program in stead of C:\"Program Files"

    Change the folder name and *.exe name. Hope this helps

    0 讨论(0)
提交回复
热议问题