找回密码
 加入
搜索
查看: 2156|回复: 8

RUN想由配置文件中读取

[复制链接]
发表于 2008-7-6 00:30:25 | 显示全部楼层 |阅读模式
#NoTrayIcon
if ProcessExists( "DF5Serv.exe" ) then
Run("e:\share.bat",""@SW_HIDE)
else
sleep(200)
endif

现在我想在上面修改下RUN是由配置文件中读取,这样就可以在配置文件中修改可执行的程序了,而且我想执行多个程序,鄙人愚蠢,请高手指点下下面的哪里错了

#NoTrayIcon
$1=IniRead(@ScriptDir&"\config.ini","config","server","")
if $1 then
if ProcessExists("DF5Serv.exe") then
Run("$1",""@SW_HIDE)
else
sleep(200)
endif
else
msgbox(64,"提醒","配置文件出错,请检查","")
endif

[ 本帖最后由 chidanchu 于 2008-7-6 04:55 编辑 ]
 楼主| 发表于 2008-7-6 00:59:22 | 显示全部楼层
我搞定了,只不过使用变量后为什么就不能能把BAT给隐藏运行了啊

#NoTrayIcon
dim $1
$1=IniRead(@ScriptDir&"config.ini","config","server","")
if $1 then
if ProcessExists("DF5Serv.exe") then
Run($1)
else
sleep(200)
endif
else
msgbox(64,"提醒","配置文件出错,请检查","")
endif

如直接run("e:pause.bat",""@SW_HIDE)为什么使用变量后就不能用run($1,""@SW_HIDE)

[ 本帖最后由 chidanchu 于 2008-7-6 01:02 编辑 ]
 楼主| 发表于 2008-7-6 02:39:28 | 显示全部楼层
#NoTrayIcon
$1=IniRead(@ScriptDir&"config.ini","config","server","")
$2=IniRead(@ScriptDir&"config.ini","config","server1","")
$3=IniRead(@ScriptDir&"config.ini","config","server2","")
Func _RunDOS( $sCommand )
    Return RunWait( @ComSpec & " /C """ & $sCommand & """", "", @SW_HIDE )
EndFunc
_RunDOS($1)
_RunDOS($2)
_RunDOS($3)

现在已经达到隐藏运行多程序的目的了,只不过不知如何与上面的配合起来,做到检测到进程才运行
发表于 2008-7-6 03:02:25 | 显示全部楼层
$softname1=IniRead("softset.ini","1","softname","")
$softname2=IniRead("softset.ini","2","softname","")
$softname3=IniRead("softset.ini","3","softname","")

$softPath1=IniRead("softset.ini","1","softpath","")
$softPath2=IniRead("softset.ini","2","softpath","")
$softPath3=IniRead("softset.ini","3","softpath","")

if $softPath1 <>"" then
                RunWait(@ScriptDir & "\" & $softPath1)
        EndIf
        if $softPath2 <>"" then
                RunWait(@ScriptDir & "\" & $softPath2)
        EndIf
        if $softPath3 <>"" then
                RunWait(@ScriptDir & "\" & $softPath3)
        EndIf

懒得修改了,复制个例子给你看看
发表于 2008-7-6 03:03:30 | 显示全部楼层
配置文件举例:


[1]
softname="7z 压缩工具"
softpath="soft\7z.exe"

[2]
softname="BitComet 去广告版(BT下载工具)"
softpath="soft\BT.exe"

[3]
softname="迅雷 5.8 去广告版"
softpath="soft\thunder.exe"
 楼主| 发表于 2008-7-6 04:55:24 | 显示全部楼层
已经解决拉
If ProcessExists("QQ.exe") <> 0 Then
$RUN = IniReadSection(@ScriptDir & "\RUN.INI", "RUNPATH")
If @error Then
  MsgBox(0, "", "INI读取不成功")
  Exit
Else
  For $i = 1 To $RUN[0][0]
   $TRUN = IniRead(@ScriptDir & "\RUN.INI", "RUNPATH", $RUN[$i][0], "")
   If $TRUN <> "" And FileExists($TRUN)<> 0 Then
    Run($RUN[$i][1], "", @SW_HIDE)
   EndIf
   Sleep(1000);多个程序间的运行间隔
  Next
EndIf
EndIf

如果路径为空,或者文件不存在则不运行

下面是INI文件格式

[RUNPATH]
1=c:\1.bat
2=c:\2.bat
3=c:\3.bat
4=c:\4.exe
发表于 2009-9-2 13:18:58 | 显示全部楼层
正好用到~学习学习
发表于 2009-9-11 17:55:09 | 显示全部楼层
正好用到~学习学习
发表于 2013-3-30 10:31:17 | 显示全部楼层
我也是正好用到,谢谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-29 07:23 , Processed in 0.097298 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表