找回密码
 加入
搜索
查看: 4805|回复: 3

[AU3基础] [已解决]au3配置文件写入读取

[复制链接]
发表于 2014-11-30 12:11:46 | 显示全部楼层 |阅读模式
本帖最后由 mshuking 于 2014-12-11 14:29 编辑

au3配置文件写入读取
#NoTrayIcon 
$RUN = IniReadSection(@ScriptDir & "\run.ini", "runpath")
If @error Then
  IniWriteSection("run.ini","runpath","1",$var)
  IniWriteSection("run.ini","runpath","2",$var)
  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
If @error Then
  IniWriteSection("run.ini","runpath","1",$var)
  IniWriteSection("run.ini","runpath","2",$var)
  Exit
这个应该怎写才是对的

下面是INI文件格式

[RUNPATH]
1=1.exe  参数              如:1=1.exe  192.168.0.251       加了参数不运行,应该怎么修改?
2=c:\4.exe
3=x.bat

帮忙修改下。。。。
发表于 2014-11-30 13:44:00 | 显示全部楼层
回复 1# mshuking
#NoTrayIcon 
Local $ini = @ScriptDir & '\run.ini'

$aSession = IniReadSection($ini, 'runpath')
If @error Then
        Local $sEXE1 = '1.exe  192.168.0.251'
        Local $sEXE2 = 'c:\4.exe'
        IniWrite($ini, 'runpath', '1', $sEXE1)
        IniWrite($ini, 'runpath', '2', $sEXE2)
        Exit
Else
        For $i = 1 To $aSession[0][0]
                $sEXE = IniRead($ini, 'runpath', $aSession[$i][0], '')
                If $sEXE <> '' And FileExists($sEXE) Then
                        Run($aSession[$i][1], '', @SW_HIDE)
                EndIf
                Sleep(1000);多个程序间的运行间隔
        Next
EndIf
 楼主| 发表于 2014-11-30 16:20:16 | 显示全部楼层
本帖最后由 mshuking 于 2014-11-30 16:24 编辑

回复 2# user3000

        Local $sEXE1 = '1.exe  192.168.0.251'
能不能写成变量  在配置文件读取 可以直接运行
RUN 读取配置文件 运行带参数的程序 不运行
发表于 2014-11-30 16:43:36 | 显示全部楼层
回复 3# mshuking

哦,那是判断的条件不对.
'1.exe  192.168.0.251'这样的文件是不存在的,所以就不运行了.
要先截取文件路径再作文件存在的判断.
For $i = 1 To $aSession[0][0]
                $sEXE = StringRegExpReplace($aSession[$i][1], '^(.+?\.\w{3,})\h?.*', '\1')
                                If Not @extended Then ContinueLoop
                                If Not FileExists($sEXE) Then ContinueLoop
                                Run($aSession[$i][1], '', @SW_HIDE)
                Sleep(1000);多个程序间的运行间隔
        Next
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 10:19 , Processed in 0.084818 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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