首页 > 其他 > 详细

dos命令调用方法

时间:2019-03-06 22:58:44      阅读:181      评论:0      收藏:0      [点我收藏+]
aauto 调用 DOS 命令

方法一、最简单的方法,直接执行DOS命令

execute("ipconfig /all")
 //不推荐,成功返回0,否则1.


方法二、用管道  //返回执行结果文本,推荐这个,没有黑窗口
import process;
f = process.popen("ipconfig /all" )
str=f.read(-1);//全部读取



方法三: 
           
import process;

//参数以/c开始,表示执行DOS命令,返回ture或者fause
process.execute_wait("cmd.exe","/c ipconfig /all")

  

定时关机例子:
import win.ui;
import process.popen; //使用process.popen(cmd)不会闪黑窗
/*DSG{{*/
mainForm = win.form(text="定时关机程序";right=582;bottom=206;mode="popup")
mainForm.add(
button={cls="button";text="执行";left=42;top=154;right=211;bottom=187;z=1};
button2={cls="button";text="取消";left=310;top=158;right=481;bottom=187;z=6};
edit={cls="edit";text="0";left=164;top=62;right=235;bottom=93;align="center";edge=1;multiline=1;z=5};
edit2={cls="edit";text="0";left=294;top=60;right=369;bottom=93;align="center";edge=1;z=8};
groupbox={cls="groupbox";text="定时关机";left=25;top=10;right=555;bottom=142;edge=1;z=2};
static={cls="static";text="Static";left=74;top=78;right=164;bottom=79;transparent=1;z=3};
static2={cls="static";text="倒计时";left=69;top=64;right=171;bottom=92;font=LOGFONT(h=-18);transparent=1;z=4};
static3={cls="static";text="分";left=255;top=68;right=312;bottom=88;font=LOGFONT(h=-18);transparent=1;z=7};
static4={cls="static";text="秒";left=398;top=68;right=433;bottom=89;font=LOGFONT(h=-18);transparent=1;z=9}
)
/*}}*/

mainForm.button.oncommand = function(id,event){
    var time=mainForm.edit.text*60+mainForm.edit2.text ;
    var cmdc ="shutdown -s"+" -t "+ time ;
    //mainForm.msgbox(cmdc)
    process.popen(cmdc);
}
 
mainForm.edit.oncommand = function(id,event){
     
}
 
mainForm.button2.oncommand = function(id,event){
      
    process.popen("shutdown -a");
    mainForm.msgbox("计划已取消")
     
}
 
mainForm.edit2.oncommand = function(id,event){
     
}
 
mainForm.show();
return win.loopMessage();

  

dos命令调用方法

原文:https://www.cnblogs.com/yaoyue68/p/10486398.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!