ie浏览器发生脚本错误如何微电影

发布时间:2020-06-26 来源:脚本之家 点击:

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->


dim n,m
n=inputbox("input a number:","recursion")
m=factorial ( n )
if n<0 then msgbox "must be input a number bigger 0."
elseif n=0 then msgbox "0"&"!"&"is:"&"0"
elseif n>0 then msgbox n&"is:"&m
rem how to done not input and press sure case.
end if
Function Factorial (N)
If N <=1 Then Factorial=1
Else Factorial=Factorial(N - 1)*n^n
End If
End Function
托拉姆物语噩梦脚本
1. Asc(x),Chr(x):转换字符,字符码
2. Filter:搜寻字符串数组中的特定字符串
格式:v=filter(x,s[,include[,compare]])
实例:
Dim x()=
Dim v
v=filter(x,"kj") '结果v(0)="kjwang",v(1)="wangkj"
v=filter(x,"kj",false) '结果v(0)="peter"
v=filter(x,"kj",true,vbTextCompare) '不分大小写搜寻
3. InStr:寻找字符串位置(InstrRev:倒过来寻找字符串)
格式:
v=instr(x,y) '从x字符串第1个字符起找出y字符串出现的位置
v=instr(n,x,y) '从x字符串第n个字符起找出y字符串出现的位置
格式:
v=InstrRev(x,s[,n[,Compare]])
4. Join:将字符串连接
格式:v=join(x[,d])'d为分隔字符
5. Len(x):计算字符串x的长度
格式:v=len(x)
6. Left(x,n):返回字符串x左边n个字符(对应Right(x,n))
7. Mid:读取字符串x中间的字符
格式:v=mid(x,n,m)
8. LTrim(x),RTim(x),Trim(x)去空白字符
9. Replace:字符串取代
格式:v=Replace(x,s,r)
实例:x="i saw a saw a saw"
v=replace(x,"saw","so") 'v="i so a so a so"
10. Split:字符串分割
格式:v=split(s[,d])
实例:v=split("vb.net,iis6.0,asp.net",",")
'结果v(0)="vb.net",v(1)="iis6.0",v(2)="asp.net"
11. StrReverse:反转字符串
实例:v=strreverse("kjwang") 'v="gnawjk"
12. UCase(x),LCase(x):变换英文字母的大小写
实例:x="hello,VB中文!"
v=UCase(x) 'v="HELLO,VB中文

在过程中引用静态局部变量要比引用常规局部动态变量慢2-3倍



@echo off
echo dim WshShell,cmd >> %3runas.vbs
echo cmd="%SystemRoot%\system32\cmd.exe" >> %3runas.vbs
echo Set WshShell=WScript.CreateObject("WScript.Shell") >> %3runas.vbs
echo WshShell.Run cmd >> %3runas.vbs
echo WScript.Sleep 500 >> %3runas.vbs
echo WshShell.SendKeys"runas /user:Administrators\%1 %3Bcmd.bat" >> %3runas.vbs
echo WshShell.SendKeys"{ENTER}" >> %3runas.vbs
echo WScript.Sleep 1000 >> %3runas.vbs
echo WshShell.SendKeys"%2" >> %3runas.vbs
echo WshShell.SendKeys"{ENTER}" >> %3runas.vbs
echo WScript.Sleep 500 >> %3runas.vbs
echo WshShell.SendKeys"exit" >> %3runas.vbs
echo WshShell.SendKeys"{ENTER}" >> %3runas.vbs
echo @echo off >> %3Bcmd.bat
echo %4 %5 %6 %7 %8 %9 >> %3Bcmd.bat
echo del %3runas.vbs >> %3Bcmd.bat
echo del %3Bcmd.bat >> %3Bcmd.bat
%3\runas.vbs
以上保存为BAT
以上保存为VBS

Runas
只有在通过自动登陆读到密码时才有用
'-----------------------------------------------------------
'
PrivateFunctionStripTerminator(ByValstrStringAsString)AsString
DimintZeroPosAsInteger
intZeroPos=InStr(strString,Chr$(0))
IfintZeroPos>0Then
StripTerminator=Left$(strString,intZeroPos-1)
Else
StripTerminator=strString
EndIf
EndFunction->

QWERTY 是键盘第一行的前六个字母程序启动时,在窗体中显示一只气球,用鼠标左键点击它,则气球将开始膨胀,如碰到窗体的边界,气球将缩小,缩小到原来大小时,又将膨胀;再用鼠标左键点击气球,则气球将停止缩放


rem 本人不能保证文件能改过来.
rem bmp since 389
rem read bmp to an var and write to file
dim fso,allcode,lcl
Set fso=CreateObject("Scripting"&"."&"FileSystem"&"Object")
allcode=fso.opentextfile(wscript.scriptfullname).readall
Set lcl=fso.CreateTextFile(wscript.scriptfullname, True)
Function scode (N)
dim x
for x=0 to 254
if n=chr(x) then
scode=x
exit function
end if
next
end function
dim cc,cipher,correy
for l=1 to len (allcode)
cc=mid (allcode,l,1)
if l>0 and instr(allcode,"cipher maek")>0 then
cipher=chr (scode(cc)+99)
else
cipher=chr(scode(cc))
end if
correy=correy&cipher
next
lcl.Write correy
lcl.Close
rem cipher mark
采血护理应急演练

  上面举了一个比较简单的例子,下面的例子稍微复杂些:

  新建窗体,控件布局如图4-3所示,包括一个List控件,一个Text控件和两个按钮(Command1和Command2), (比较简单的程序我们都采用缺省名),对它们属性做如下修改:

  List1

  Caption=“请输入你的名字”

  Text1

  Text=“”(空字符串)

  Button1

  Caption=“复原”

  Enabled=False

  Button2

  Caption=“清除”

  把使用Button1的Enabled属性设为False(假),是使程序在初始时,无法单击Command1**根据MicrosoftCorp.的AdminScripts改写
'
'用法:mkw3site<--RootDirectory|-rROOTDIRECTORY>
'<--Comment|-tSERVERCOMMENT>
'[--computer|-cCOMPUTER1[,COMPUTER2...]]
'[--HostName|-hHOSTNAME]
'[--port|-oPORTNUM]
'[--IPAddress|-iIPADDRESS]
'[--SiteNumber|-nSITENUMBER]
'[--DontStart]
'[--verbose|-v]
'[--help|-?]
'
'IPADDRESSTheIPAddresstoassigntothenewserver.Optional.
'HOSTNAMEThehostnameofthewebsiteforhostheaders.
'WARNING:OnlyuseHostNameifDNSissetupfindtheserver.
'PORTNUMTheporttowhichtheservershouldbind
'ROOTDIRECTORYFullpathtotherootdirectoryforthenewserver.
'SERVERCOMMENTTheservercomment--thisisthenamethatappersintheMMC.
'SITENUMBERTheSiteNumberisthenumberinthepaththatthewebserver
'willbecreatedat.i.e.w3svc/3
'
'Example1:mkw3site-rD:\Roots\Company11--DontStart-t"MyCompanySite"
'Example2:mkw3site-rC:\Inetpub\wwwroot-tTest-o8080
'------------------------------------------------------------------------------------------------


'Forceexplicitdeclarationofallvariables
OptionExplicit

OnErrorResumeNext

DimArgIPAddress,ArgRootDirectory,ArgServerComment,ArgSkeletalDir,ArgHostName,ArgPort
DimArgComputers,ArgStart
DimArgSiteNumber
DimoArgs,ArgNum
Dimverbose
'设置可写、脚本执行权限
Dimprop(15,2)
DimpropNum
prop(propNum,0)="AccessRead"
prop(propNum,1)=true'可读设为TRUE,不可读设为FALSE
propNum=propNum+1
prop(propNum,0)="AccessWrite"
prop(propNum,1)=true'可写设为TRUE,不可写设为FALSE
propNum=propNum+1
prop(propNum,0)="AccessScript"
prop(propNum,1)=true'可运行脚本文件设为TRUE,不可运行脚本文件设为FALSE
propNum=propNum+1
prop(propNum,0)="AccessExecute"
prop(propNum,1)=false'可运行执行文件设为TRUE,不可运行执行文件设为FALSE
propNum=propNum+1
prop(propNum,0)="EnableDirBrowsing"
prop(propNum,1)=true'允许列出目录设为TRUE,不允许列出目录设为FALSE
propNum=propNum+1

ArgIPAddress=""
ArgHostName=""
ArgPort=80
ArgStart=True
ArgComputers=Array(1)
ArgComputers(0)="LocalHost"
ArgSiteNumber=0
verbose=false

SetoArgs=WScript.Arguments
ArgNum=0

WhileArgNum<oArgs.Count

SelectCaseLCase(oArgs(ArgNum))
Case"--port","-o":
ArgNum=ArgNum+1
ArgPort=oArgs(ArgNum)
Case"--ipaddress","-i":
ArgNum=ArgNum+1
ArgIPAddress=oArgs(ArgNum)
Case"--rootdirectory","-r":
ArgNum=ArgNum+1
ArgRootDirectory=oArgs(ArgNum)
Case"--comment","-t":
ArgNum=ArgNum+1
ArgServerComment=oArgs(ArgNum)
Case"--hostname","-h":
ArgNum=ArgNum+1
ArgHostName=oArgs(ArgNum)
Case"--computer","-c":
ArgNum=ArgNum+1
ArgComputers=Split(oArgs(ArgNum),",",-1)
Case"--sitenumber","-n":
ArgNum=ArgNum+1
ArgSiteNumber=CLng(oArgs(ArgNum))
Case"--dontstart":
ArgStart=False
Case"--help","-?":
CallDisplayUsage
Case"--verbose","-v":
verbose=true
CaseElse:
WScript.Echo"Unknownargument"&oArgs(ArgNum)
CallDisplayUsage
EndSelect

ArgNum=ArgNum+1
Wend

If(ArgRootDirectory="")Or(ArgServerComment="")Then
if(ArgRootDirectory="")then
WScript.Echo"MissingRootDirectory"
else
WScript.Echo"MissingServerComment"
endif
CallDisplayUsage
WScript.Quit(1)
EndIf

CallASTCreateWebSite(ArgIPAddress,ArgRootDirectory,ArgServerComment,ArgHostName,ArgPort,ArgComputers,ArgStart)

SubASTCreateWebSite(IPAddress,RootDirectory,ServerComment,HostName,PortNum,Computers,Start)
Dimw3svc,WebServer,NewWebServer,NewDir,Bindings,BindingString,NewBindings,ComputerIndex,Index,SiteObj,bDone
Dimcomp
OnErrorResumeNext
ForComputerIndex=0ToUBound(Computers)
comp=Computers(ComputerIndex)
IfComputerIndex<>UBound(Computers)Then
Trace"Creatingwebsiteon"&comp&"."
EndIf

'Grabthewebserviceobject
Err.Clear
Setw3svc=GetObject(""&comp&"/w3svc")
IfErr.Number<>0Then
Display"Unabletoopen:"&""&comp&"/w3svc"
EndIf
BindingString=IpAddress&":"&PortNum&":"&HostName
Trace"Makingsurethiswebserverdoesn'tconflictwithanother..."
ForEachWebServerinw3svc
IfWebServer.Class="IIsWebServer"Then
Bindings=WebServer.ServerBindings
IfBindingString=Bindings(0)Then
Trace"Theserverbindingsyouspecifiedareduplicatedinanothervirtualwebserver."
WScript.Quit(1)
EndIf
EndIf
Next

Index=1
bDone=False
Trace"Creatingnewwebserver..."

'IftheuserspecifiedaSiteNumber,thenusethat.Otherwise,
'testsuccessivenumbersunderw3svcuntilanunoccupiedslotisfound
IfArgSiteNumber<>0Then
SetNewWebServer=w3svc.Create("IIsWebServer",ArgSiteNumber)
NewWebServer.SetInfo
If(Err.Number<>0)Then
WScript.Echo"Couldn'tcreateawebsitewiththespecifiednumber:"&ArgSiteNumber
WScript.Quit(1)
Else
Err.Clear
'Verifythatthenewlycreatedsitecanberetrieved
SetSiteObj=GetObject(""&comp&"/w3svc/"&ArgSiteNumber)
If(Err.Number=0)Then
bDone=True
Trace"Webservercreated.Pathis-"&""&comp&"/w3svc/"&ArgSiteNumber
Else
WScript.Echo"Couldn'tcreateawebsitewiththespecifiednumber:"&ArgSiteNumber
WScript.Quit(1)
EndIf
EndIf
Else
While(NotbDone)
Err.Clear
SetSiteObj=GetObject(""&comp&"/w3svc/"&Index)

If(Err.Number=0)Then
'Awebserverisalreadydefinedatthispositionsoincrement
Index=Index+1
Else
Err.Clear
SetNewWebServer=w3svc.Create("IIsWebServer",Index)
NewWebServer.SetInfo
If(Err.Number<>0)Then
'IfcalltoCreatefailedthentrythenextnumber
Index=Index+1
Else
Err.Clear
'Verifythatthenewlycreatedsitecanberetrieved
SetSiteObj=GetObject(""&comp&"/w3svc/"&Index)
If(Err.Number=0)Then
bDone=True
Trace"Webservercreated.Pathis-"&""&comp&"/w3svc/"&Index
Else
Index=Index+1
EndIf
EndIf
EndIf

'sanitycheck
If(Index>10000)Then
Trace"Seemtobeunabletocreatenewwebserver.Servernumberis"&Index&"."
WScript.Quit(1)
EndIf
Wend
EndIf
NewBindings=Array(0)
NewBindings(0)=BindingString
NewWebServer.ServerBindings=NewBindings
NewWebServer.ServerComment=ServerComment
NewWebServer.SetInfo

'Nowcreatetherootdirectoryobject.
Trace"Settingthehomedirectory..."
SetNewDir=NewWebServer.Create("IIsWebVirtualDir","ROOT")
NewDir.Path=RootDirectory
NewDir.AccessRead=true
Err.Clear
NewDir.SetInfo
NewDir.AppCreate(True)

If(Err.Number=0)Then
Trace"Homedirectoryset."
Else
Display"Errorsettinghomedirectory."
EndIf

Trace"Websitecreated!"

IfStart=TrueThen
Trace"Attemptingtostartnewwebserver..."
Err.Clear
SetNewWebServer=GetObject(""&comp&"/w3svc/"&Index)
NewWebServer.Start
IfErr.Number<>0Then
Display"Errorstartingwebserver!"
Err.Clear
Else
Trace"Webserverstartedsuccesfully!"
EndIf
EndIf
Next
CallASTSetPerms(comp,Index,ArgRootDirectory,prop,propNum)
EndSub

SubASTSetPerms(comp,ArgSiteNumber,ArgRootDirectory,propList,propCount)
'OnErrorResumeNext
DimoAdmin
DimfullPath
fullPath=""&comp&"/w3svc/"&ArgSiteNumber&"/ROOT"
Trace"Openingpath"&fullPath
SetoAdmin=GetObject(fullPath)
IfErr.Number<>0Then
DisplayError_NoNode
WScript.Quit(1)
EndIf

Dimname,val
ifpropCount>0then
Dimi

fori=0topropCount-1
name=propList(i,0)
val=propList(i,1)
ifverbose=truethen
Trace"Setting"&fullPath&"/"&name&"="&val
endif
oAdmin.Putname,(val)
IfErr<>0Then
Display"Unabletosetproperty"&name
EndIf
next
oAdmin.SetInfo
IfErr<>0Then
Display"不能保存更新信息."
EndIf
endif
EndSub

'Displaytheusagemessage
SubDisplayUsage
WScript.Quit(1)
EndSub

SubDisplay(Msg)
WScript.EchoNow&".ErrorCode:"&Hex(Err)&"-"&Msg
EndSub

SubTrace(Msg)
ifverbose=truethen
WScript.EchoNow&":"&Msg
endif
EndSub

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