请教把这VBS转为AU3
Dim iSetmenu:iSetmenu=1Dim 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)
小弟在此静候结果,先谢谢 我帮你顶 我不熟悉VB 要是批处理么 我也许能帮上你:face (23): 多谢二楼的朋友 这个是什么?要实现什么功能? 回复 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 ;==>_runvbsINI文件名 config.ini
Globaldir = "E:\lujing\"
Setmenu = "file.dat"
Baidurl = "http://www.baidu.com/"
Setting = "http://www.hao123.com" 感谢版主
脚本运行时提示 请求动作失败(请求于对象)
页:
[1]