找回密码
 加入
搜索
查看: 2566|回复: 4

[系统综合] [已解决]开机自启动程序iniRead()的问题

[复制链接]
发表于 2011-7-3 09:34:47 | 显示全部楼层 |阅读模式
本帖最后由 linnsky 于 2011-7-3 10:10 编辑

一个开机自启动的小脚本,读取EyooPage.dat中的配置,写入到D:\UserData$\Globalconfig\SetMenu.dat中,编译成功后,直接双击编译好的程序执行没有问题,可以从EyooPage.dat中读取到相关键值,但是把此程序加入系统启动项,无论是放到启动文件夹,还是注册表的Run下,开机后他不去读取EyooPage.dat,而是直接使用默认值,特此求助~!
Func Home()
        Local $time = IniRead("EyooPage.dat", "HomePage", "Time", "20") * 1000
        Sleep($time)
        Local $file = IniRead("EyooPage.dat", "HomePage", "Dir", "D:\UserData$\Globalconfig\SetMenu.dat")
        Local $home = IniRead("EyooPage.dat", "HomePage", "Home", "http://25759.5258.net/")
        MsgBox(4096 , "Test" , $home)
        IniWrite($file, "Setup", "StartPage", $home)
EndFunc

Func OneHome()
        Local $file = IniRead("EyooPage.dat", "HomePage", "Dir", "D:\UserData$\Globalconfig\SetMenu.dat")
        Local $home = IniRead("EyooPage.dat", "HomePage", "Home", "http://25759.5258.net/")
        MsgBox(4096 , "Test" , $home)
        IniWrite($file, "Setup", "StartPage", $home)
EndFunc


Func Main()
        Sleep(60000)
        FileCreateShortcut(@ScriptFullPath , "C:\Documents and Settings\Administrator\「开始」菜单\程序\启动\EyooPage.lnk")
        OneHome()
        While 1
                Home()
        WEnd
EndFunc

Main()
发表于 2011-7-3 09:57:46 | 显示全部楼层
回复 1# linnsky


楼主的写法真够古怪,先写自定义函数再写运行代码
Main()
Func Main()
        FileChangeDir(@ScriptDir)
        Sleep(60000)
        FileCreateShortcut(@ScriptFullPath , "C:\Documents and Settings\Administrator\「开始」菜单\程序\启动\EyooPage.lnk")
        OneHome()
        While 1
                Home()
        WEnd
EndFunc
Func Home()
        Local $time = IniRead("EyooPage.dat", "HomePage", "Time", "20") * 1000
        Sleep($time)
        Local $file = IniRead("EyooPage.dat", "HomePage", "Dir", "D:\UserData$\Globalconfig\SetMenu.dat")
        Local $home = IniRead("EyooPage.dat", "HomePage", "Home", "http://25759.5258.net/")
        MsgBox(4096 , "Test" , $home)
        IniWrite($file, "Setup", "StartPage", $home)
EndFunc

Func OneHome()
        Local $file = IniRead("EyooPage.dat", "HomePage", "Dir", "D:\UserData$\Globalconfig\SetMenu.dat")
        Local $home = IniRead("EyooPage.dat", "HomePage", "Home", "http://25759.5258.net/")
        MsgBox(4096 , "Test" , $home)
        IniWrite($file, "Setup", "StartPage", $home)
EndFunc
 楼主| 发表于 2011-7-3 10:01:58 | 显示全部楼层
回复 2# tryhi

谢楼上指正,把运行代码放到前面,效果还是那样,我在一楼有描述
发表于 2011-7-3 10:03:08 | 显示全部楼层
本帖最后由 tryhi 于 2011-7-3 10:05 编辑
回复  tryhi

谢楼上指正,把运行代码放到前面,效果还是那样,我在一楼有描述
linnsky 发表于 2011-7-3 10:01


我只是简单的代码放前面吗?我不是还加了一句?

另外你这种写法顺序对于运行没有任何区别,只不过看起来没那么严谨
 楼主| 发表于 2011-7-3 10:09:44 | 显示全部楼层
回复 4# tryhi

Sorry,没有仔细看
        FileChangeDir(@ScriptDir)
原来是因为路径的原因,非常感谢,您说的对,编码习惯得改
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-1 23:48 , Processed in 0.087550 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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