`

一个小脚本遇到的问题之 Windows 命令行启动程序

阅读更多

     Windows命令行执行程序,吃力不讨好的事情,不过谁让咱们懒呢。试试呗。
     以前记得有个start命令可以使用,当然网络上面很多说直接加入环境变量的,这个方法可以不过我没用。 Windows 的环境变量改来改去太麻烦。还是死磕start这个命令比较靠谱。
     还真有,而且试过还不错。具体代码如下:

start " " "full path"


    上面这种形式比较安全。当然直接执行没有空格的路径也是可以的。具体可以参考这里:批处理启动多个程序
    应该是能用,不过我的 Windows 8.1居然在命令行可以执行,写入bat文件居然不可以了。我就郁闷了。(换了一台其他的就可以,我实在是呵呵了。)
    下面为了体谅我的老电脑,所以中间需要给个两三秒的休息时间。
    参考的内容如下:http://stackoverflow.com/a/1672349
    http://stackoverflow.com/a/1672375

ping 127.0.0.1 -n 6 > nul
127.0.0.1 is the localhost IP address.
-n 6 There is a 1s delay between each ping, so for a 5s delay you need to do 6 pings.
nul gobble the output.

# 简单粗暴型
C:\> timeout 5
N.B. Please note however (thanks Dan!) that timeout 5 means:

Sleep anywhere between 4 and 5 seconds
This can be verified empirically by putting the following into a batch file, running it repeatedly and calculating the time differences between the first and second echos:

@echo off
echo %time%
timeout 5 > NUL
echo %time%


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics