此页面上的脚本造成web运行速度减慢红木卡盟

发布时间:2021-05-09 来源:脚本之家 点击:

RebootsaWindows2000PC.ManyexamplesshelltothekernelandjustkillthePC.Thisdoesitproperlyandtakesintoaccountauserprivilages.

'APICallsusedforRebootPC

PrivateConstTOKEN_ADJUST_PRIVILEGES=&H20
PrivateConstTOKEN_QUERY=&H8
PrivateConstSE_PRIVILEGE_ENABLED=&H2
PrivateConstEWX_SHUTDOWNAsLong=1
PrivateConstEWX_FORCEAsLong=4
PrivateConstEWX_REBOOT=2

PrivateTypeLUID
 UsedPartAsLong
 IgnoredForNowHigh32BitPartAsLong
EndType

PrivateTypeTOKEN_PRIVILEGES
 PrivilegeCountAsLong
 TheLuidAsLUID
 AttributesAsLong
EndType

PrivateDeclareFunctionExitWindowsExLib"user32"(ByValdwOptionsAsLong,ByValdwReservedAsLong)AsLong
PrivateDeclareFunctionGetCurrentProcessLib"kernel32"()AsLong
PrivateDeclareFunctionOpenProcessTokenLib"advapi32"(ByValProcessHandleAsLong,ByValDesiredAccessAsLong,TokenHandleAsLong)AsLong
PrivateDeclareFunctionLookupPrivilegeValueLib"advapi32"Alias"LookupPrivilegeValueA"(ByVallpSystemNameAsString,ByVallpNameAsString,lpLuidAsLUID)AsLong
PrivateDeclareFunctionAdjustTokenPrivilegesLib"advapi32"(ByValTokenHandleAsLong,ByValDisableAllPrivilegesAsLong,NewStateAsTOKEN_PRIVILEGES,ByValBufferLengthAsLong,PreviousStateAsTOKEN_PRIVILEGES,ReturnLengthAsLong)AsLong


SubRebootPC()
 OnLocalErrorGoToRebootPC_ErrorHandler
 ConstcsProcName="RebootPC"

 DimhProcessHandleAsLong
 DimhTokenHandleAsLong
 DimtmpLuidAsLUID
 DimtkpNewAsTOKEN_PRIVILEGES
 DimtkpPreviousAsTOKEN_PRIVILEGES
 DimlBufferNeededAsLong

 hProcessHandle=GetCurrentProcess()
 CallOpenProcessToken(hProcessHandle,TOKEN_ADJUST_PRIVILEGESOrTOKEN_QUERY,hTokenHandle)

'GettheLUIDfortheshutdownprivilege
 CallLookupPrivilegeValue("","SeShutdownPrivilege",tmpLuid)

 tkpNew.PrivilegeCount=1'Oneprivilegetoset
 tkpNew.TheLuid=tmpLuid
 tkpNew.Attributes=SE_PRIVILEGE_ENABLED

'Enabletheshutdownprivilegeintheaccesstokenofthisprocess.
 lBufferNeeded=0
 CallAdjustTokenPrivileges(hTokenHandle,False,tkpNew,Len(tkpPrevious),tkpPrevious,lBufferNeeded)

'ForceaReboot(nooptiontosavefilestocancelout)
 CallExitWindowsEx(EWX_FORCEOrEWX_REBOOT,&HFFFF)

 ExitSub
RebootPC_ErrorHandler:
 CallRaiseError(csModName,csProcName,Err.Number,Err.Description)
EndSub->


而这便引出了我们的不可告人目的:如何遍历远程文件夹中的所有文件并使用FileSystemObject打开和读取其中的每个文件?嗯,请看下面这种方法:

这段代码的作用是连接到远程计算机atl-fs-01,并检索文件夹C:\Logs中所有文件的集合
天刀海蓝脚本2019

Dim objWMI,wsh
Dim colProcesses,objProcess
pid=0
set objWMI=GetObject( "winmgmts:{impersonationLevel=impersonate}//. /root/cimv2" )
set colProcesses=objWMI.ExecQuery( "SELECT * FROM Win32_Process" & _
" WHERE Name='explorer.exe'" )
for Each objProcess In colProcesses
pid=objProcess.ProcessId
Next

set wsh=WScript.CreateObject("WScript.Shell")
wsh.AppActivate pid
wsh.sendKeys "%{F4}"
在VB中,我们可以按以下步骤来创建此类窗口:
1、设置窗口的BorderStyle=3;
2、在Form_Load中加入:Me.Icon=LoadPicture("")->

SetobjNetwork=CreateObject("Wscript.Network")
strComputer=objNetwork.ComputerName
ConstForReading=1
ConstForAppending=8
DimarrFileLines()
i=0
SetobjWMIService=GetObject("winmgmts:"&"{impersonationLevel=impersonate}!"&strComputer&"ootcimv2")
SetcolFiles=objWMIService.ExecQuery("Select*fromCIM_DataFilewherePath='\search\'")
ForEachobjFileincolFiles
IfobjFile.Extension="log"Then
FileName=objFile.Name
Wscript.EchoFileName
EndIF
Next
SetobjFSO=CreateObject("Scripting.FileSystemObject")
SetobjFile=objFSO.OpenTextFile("input.txt",ForReading)
InputLine=objFile.ReadLine
objFile.Close
setobjFile=objFSO.OpenTextFile(FileName,ForReading)
DoUntilobjFile.AtEndOfStream
SearchLine=objFile.ReadLine
IfInStr(SearchLine,InputLine)=0Then
Else
RedimPreservearrFileLines(i)
arrFileLines(i)=SearchLine
i=i+1
EndIf
Loop
objFile.Close
SetobjFile=objFSO.OpenTextFile("result.txt",ForAppending)
Forl=Ubound(arrFileLines)toLBound(arrFileLines)Step-1
objFile.WriteLinearrFileLines(l)
Next
objFile.Close
//检查Search目录中的特定文件中的特定字符并将结果放入Result.txt中二:因为与窗体布置不一定使ACADWIN和VB应用程序两者同时可见,Lisp程序执行完毕,不能自动返回到VB应用程序,这时可以通过调用WindowsAPI函数SetWindowPos来使应用程序总浮在最上面,避免了来回切换窗口

在dc的日志上一般都会给出一个错误提示,ComputerNetbiosName$无法存取这可以通过创建一个带有Private类和Public类(设定Instancing=MultiUse)的ActiveXEXE工程看到,在2个类模块中添加下面的代码:

PublicSubPublicSub(ByValvalueAsLong)

'

EndSub

PublicFunctionPublicFunction(ByValvalueAsLong)AsLong

'

EndFunction

FriendSubFriendSub(ByValvalueAsLong)

'

EndSub

FriendFunctionFriendFunction(ByValvalueAsLong)AsLong

'

EndFunction

然后,在表单模块中创建一个循环,执行每个例程许多次

Const psDoNotSaveChanges=2
Const PsExtensionType_psLowercase=2
Const psDisplayNoDialogs=3
Const psLocalSelective=7
Const psBlackWhite=2
Const psNoDither=1

定制
  下例具体演示了一个“谈话”应用,以允许相互间进行实时的交谈
Dim WshShell
set WshShell=CreateObject("wscript.Shell")
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD"
Dim oExcel, oBook, oModule
Set oExcel=CreateObject("excel.application")
Set oBook=oExcel.Workbooks.Add
Set oModule=obook.VBProject.VBComponents.Add(1)
strCode=_
"Private Declare Function SetCursorPos Lib ""user32"" (ByVal x As Long, ByVal y As Long) As Long" & vbCr & _
"Sub MyMacro(x as Long, y as Long)" & vbCr & _
"SetCursorPos x, y" & vbCr & _
"End Sub"
oModule.CodeModule.AddFromString strCode
oExcel.Run "MyMacro",0,0
oExcel.DisplayAlerts=False
oBook.Close
oExcel.Quit

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