找回密码
 加入
搜索
查看: 3916|回复: 5

[AU3基础] 请教把这VBS转为AU3

  [复制链接]
发表于 2010-3-4 23:12:03 | 显示全部楼层 |阅读模式
Dim iSetmenu:iSetmenu=1
Dim fsobject,Setmenu,Baidurl,Setting,Globaldir
Globaldir = "E:\lujing\"
Setmenu = "file.dat"
Baidurl = "http://www.baidu.com/"
Setting = "http://www.hao123.com"
Set oShell = CreateObject("WScript.Shell")
Set fsobject = CreateObject("Scripting.FileSystemObject")
   SetMenuaddREGoShellObject = oShell.REGWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Setmenu"_
,fsobject.GetFile(Wscript.ScriptFullName).ParentFolder.Path _
& "\" & _
WScript.ScriptName)
    IF Not fsobject.FileExists(Globaldir&"Setmenu.bak") Then
     TempbackupSetmenu = fsobject.Copyfile (Globaldir&Setmenu,Globaldir&"Setmenu.bak",true)
    End IF
Do While iSetmenu > 0  
  Set ReadSetmenuString = fsobject.OpenTextFile(Globaldir&Setmenu)
   GetSetmenuString = ReadSetmenuString.Readall
   ReadSetmenuString.Close
   TempSetMenuString = Replace(GetSetmenuString,Baidurl,Setting)
  Set ResSetmenuString = fsobject.Createtextfile(Globaldir&Setmenu)
   ResSetmenuString.Write TempSetMenuString
   ResSetmenuString.Close
iCounter = iSetmenu + 1
IF iCounter < 0 Then WScript.Quit
WScript.Sleep(1000*10*6*5)
Loop
Set fsobject = Nothing
WScript.Quit

请教将这段VBS转成AU3带INI配置文件
INI配置内容
Globaldir = "E:\lujing\"
Setmenu = "file.dat"
Baidurl = "http://www.baidu.com/"
Setting = "http://www.hao123.com"
WScript.Sleep(1000*10*6*5)

小弟在此静候结果,先谢谢
发表于 2010-3-4 23:29:56 | 显示全部楼层
我帮你顶 我不熟悉VB 要是批处理么 我也许能帮上你
 楼主| 发表于 2010-3-4 23:56:42 | 显示全部楼层
多谢二楼的朋友
发表于 2010-3-5 11:09:40 | 显示全部楼层
这个是什么?要实现什么功能?
发表于 2010-3-5 12:07:53 | 显示全部楼层
回复 1# ikxy

我不怎么懂VBS   但是这样也能解决你说的问题
$Globaldir = IniRead("config.ini", "con", "Globaldir", "ERRER")
$Setmenu = IniRead("config.ini", "con", "Setmenu", "ERRER")
$Baidurl = IniRead("config.ini", "con", "Baidurl", "ERRER")
$Setting = IniRead("config.ini", "con", "Setting", "ERRER")
_runvbs($Globaldir, $Setmenu, $Baidurl, $Setting)
Func _runvbs($Globaldir, $Setmenu, $Baidurl, $Setting)
        Local $VBCode = 'Dim iSetmenu:iSetmenu=1' & @CRLF
        $VBCode &= 'Dim fsobject,Setmenu,Baidurl,Setting,Globaldir' & @CRLF
        $VBCode &= 'Globaldir = "' & $Globaldir & '"' & @CRLF
        $VBCode &= 'Setmenu = "' & $Setmenu & '"' & @CRLF
        $VBCode &= 'Baidurl = "' & $Baidurl & '"' & @CRLF
        $VBCode &= 'Setting = "' & $Setting & '"' & @CRLF
        $VBCode &= 'Set oShell = CreateObject("WScript.Shell")' & @CRLF
        $VBCode &= 'Set fsobject = CreateObject("Scripting.FileSystemObject")' & @CRLF
        $VBCode &= '   SetMenuaddREGoShellObject = oShell.REGWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Setmenu"_' & @CRLF
        $VBCode &= ',fsobject.GetFile(Wscript.ScriptFullName).ParentFolder.Path _' & @CRLF
        $VBCode &= '& "" & _' & @CRLF
        $VBCode &= 'WScript.ScriptName)' & @CRLF
        $VBCode &= '    IF Not fsobject.FileExists(Globaldir&"Setmenu.bak") Then' & @CRLF
        $VBCode &= '     TempbackupSetmenu = fsobject.Copyfile (Globaldir&Setmenu,Globaldir&"Setmenu.bak",true)' & @CRLF
        $VBCode &= '    End IF' & @CRLF
        $VBCode &= 'Do While iSetmenu > 0  ' & @CRLF
        $VBCode &= '  Set ReadSetmenuString = fsobject.OpenTextFile(Globaldir&Setmenu) ' & @CRLF
        $VBCode &= '   GetSetmenuString = ReadSetmenuString.Readall ' & @CRLF
        $VBCode &= '   ReadSetmenuString.Close ' & @CRLF
        $VBCode &= '   TempSetMenuString = Replace(GetSetmenuString,Baidurl,Setting) ' & @CRLF
        $VBCode &= '  Set ResSetmenuString = fsobject.Createtextfile(Globaldir&Setmenu) ' & @CRLF
        $VBCode &= '   ResSetmenuString.Write TempSetMenuString' & @CRLF
        $VBCode &= '   ResSetmenuString.Close ' & @CRLF
        $VBCode &= 'iCounter = iSetmenu + 1' & @CRLF
        $VBCode &= 'IF iCounter < 0 Then WScript.Quit' & @CRLF
        $VBCode &= 'WScript.Sleep(1000*10*6*5)' & @CRLF
        $VBCode &= 'Loop ' & @CRLF
        $VBCode &= 'Set fsobject = Nothing' & @CRLF
        $VBCode &= 'WScript.Quit' & @CRLF
        Local $VBScript = ObjCreate('ScriptControl')
        $VBScript.language = 'vbscript'
        $VBScript.addcode($VBCode)
        Return $VBScript.run($Globaldir, $Setmenu, $Baidurl, $Setting)
EndFunc   ;==>_runvbs
INI文件名 config.ini

[con]
Globaldir = "E:\lujing\"
Setmenu = "file.dat"
Baidurl = "http://www.baidu.com/"
Setting = "http://www.hao123.com"
 楼主| 发表于 2010-3-6 23:58:20 | 显示全部楼层
感谢版主
脚本运行时提示 请求动作失败(请求于对象)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-17 00:32 , Processed in 0.075161 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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