<p>'*********************************************<br />'*by r05e<br />'*转换日志保存的目录<br />'*********************************************<br />Set WshShell=CreateObject("Wscript.Shell")<br />Set fso=CreateObject("Scripting.FileSystemObject")<br />Function input()<br />choevt=InputBox("请输入要更改日志保存文件的日志编号:"&vbCrLf&"1-------------Application"&vbCrLf&"2-------------DNS Server"&vbCrLf&"3-------------Security"&vbCrLf&"4-------------System","选择要更改保存文件的日志文件", "1", 100, 100)<br />evtItem=InputBox("请输入一个绝对路径"," 更改日志保存文件", "%SystemRoot%\system32\config\AppEvent.Evt", 100, 100)</p><p> </p><p>If choevt<>"" and evtItem<>"" Then<br />If IsNumeric(choevt) and choevt<5 and choevt>0 Then</p><p>If choevt=1 Then<br />evt="Application"<br />ElseIf choevt=2 Then<br />evt="DNS Server"<br />ElseIf choevt=3 Then<br />evt="Security"<br />ElseIf choevt=4 Then<br />evt="System"<br />End If<br />If (Not fso.FileExists(evtItem)) Then<br />wscript.echo "文件不存在或没有用绝对路径,请重新输入"<br />wscript.sleep 1000<br />input()<br />End If<br />On Error Resume Next</p><p>sregval = WshShell.RegRead("HKLM\System\CurrentControlSet\Services\Eventlog\"&evt&"\File")<br />If Err.Number <> 0 Then<br /> wscript.echo "你的主机不具备这项日志功能,请重新输入"<br /> wscript.sleep 1000<br />input()</p><p>Else <br />WshShell.RegWrite "HKLM\System\CurrentControlSet\Services\Eventlog\"&evt&"\File",evtItem,"REG_EXPAND_SZ"<br />wscript.echo "操作成功"<br />End If<br />On Error GoTo 0<br />Else wscript.echo "输入有误,请重新输入"<br />wscript.sleep 1000<br />input()</p><p>End If</p><p>ElseIf choevt="" and evtItem="" Then<br />wscript.echo "操作已经取消"<br />Else wscript.echo "输入有误,请重新输入"<br />wscript.sleep 1000<br />input()<br />End If<br />End Function<br />input()<br />set WshShell=nothing<br />set fso=nothing</p> |
|