Problem with the start /wait command

◇◆丶佛笑我妖孽 提交于 2019-12-24 10:47:49

问题


            @echo off
            start /wait notepad
            start worpad

This is the code i have written in a batch file. My aim is to stop the batch file execution till the notepad application gets closed. Its working perfect but the thing is, Its displaying the command prompt also .Its opening the command prompt when i execute

     start /wait notepad in my batch file. 

The command prompt gets closed when i close my notepad. But i dont want the command prompt.How do i make that. I even tried these

    cmd /c start /wait notepad

even the above command is not working. How do i make it.How do i open only notepad without the command prompt and wait till it is closed ?


回答1:


As I said in my answer to one of your previous questions, the command prompt window is there because it is the tool that processes the batch file. The command prompt window is the working window of the CMD.EXE program, just like Notepad's working window is the one where you are editing text files. Typically, running a program with its working window hidden is a non-trivial task, unless the program has a pre-defined mode of running with the hidden window. As it happens, CMD does not have such a mode.

However, there is a way of starting a program with its window minimised. You only need to create a shortcut to your program (it can be a batch file too), then open the shortcut's properties, and on the Shortcut tab, set the Run property to Minimized. To make it clearer, here's an illustration:




回答2:


Or maybe you can just use the

ping localhost -n ( your time in second ) >nul

So your code will be like this

@echo off

start notepad

ping localhost -n ( your time in second ) >nul

start worpad



来源:https://stackoverflow.com/questions/6746696/problem-with-the-start-wait-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!