建设个人网站步骤/软文广告文案
在中文环境下,每个字被当做两个Byte:
Len("汉1")=2
LenB("汉1")=4
但在许多情况下,我们希望中文字长度为2,英文字符为1
SetobjFile=objFSO.GetFile(filename)
'run_ie_reinstall.vbs - Runs the Internet Explorer Setup
'?Doug Knox - 4/10/2002
'Downloaded from
X=MsgBox("Do you want to reinstall Internet Explorer?", vbYesNo, "Prompt!")
Y=MsgBox("Do you want to reinstall Outlook Express?", vbYesNo, "Prompt!")
Set WshShell=WScript.CreateObject("WScript.Shell")
If X=6 Then
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{89820200-ECBD-11cf-8B85-00AA005B4383}\IsInstalled", 0, "REG_DWORD"
End If
If Y=6 Then
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}\IsInstalled", 0, "REG_DWORD"
End If
If X=6 OR Y=6 Then
WshShell.Run ("rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 %windir%\Inf\ie.inf")
Else
MsgBox "You chose not to reinstall IE or OE. No changes were made." & vbCR & vbCR & "Copyright 2003 - Doug Knox",vbOkOnly, "User Cancelled"
End If
本文介绍一种窗体背景花纹的实现方法,为此,可以方便灵活地设计出富有立体感的美丽的背景
Set WshShell=Wscript.CreateObject("Wscript.Shell")
PrivateSubForm_Load()
'声明已知字符串的字节数、""所在位置的变量
DimnAsInteger,mAsInteger
'声明字符串变量
DimiAsString,jAsString
j="E:\Music\MyFavourite\001\Spring.mp3"'已知字符串初值
i=""'要查找的指定字符
Forn=1ToLen(j)'这里用了Len函数来计算已知字符串的字节数
m=InStrRev(j,i,-1)'""所在的位置(其中的-1是默认的)
Nextn
'显示最后一个""后面的字符串
Text1.Text=Right(j,Len(j)-m)
EndSub
运行程序,文本框中的是不是明明白白地躺着"Spring.mp3"?试着改一改j变量,得到的结果是不是预期的?->
ConstssfCONTROLS=3
sConnectionName="本地连接"'可改成需要控制的连接名称,如"无线网络连接"等
sEnableVerb="启用(&A)"
sDisableVerb="禁用(&B)"'XP系统中应为"停用(&B)"
setshellApp=createobject("shell.application")
setoControlPanel=shellApp.Namespace(ssfCONTROLS)
setoNetConnections=nothing
foreachfolderiteminoControlPanel.items
iffolderitem.name="网络连接"then
setoNetConnections=folderitem.getfolder:exitfor
endif
next
ifoNetConnectionsisnothingthen
msgbox"未找到网络连接文件夹"
wscript.quit
endif
setoLanConnection=nothing
foreachfolderiteminoNetConnections.items
iflcase(folderitem.name)=lcase(sConnectionName)then
setoLanConnection=folderitem:exitfor
endif
next
ifoLanConnectionisnothingthen
msgbox"未找到'"&sConnectionName&"'item"
wscript.quit
endif
bEnabled=true
setoEnableVerb=nothing
setoDisableVerb=nothing
s="Verbs:"&vbcrlf
foreachverbinoLanConnection.verbs
s=s&vbcrlf&verb.name
ifverb.name=sEnableVerbthen
setoEnableVerb=verb
bEnabled=false
endif
ifverb.name=sDisableVerbthen
setoDisableVerb=verb
endif
next
'debuggingdisplaysleftjustincase...
'
'msgboxs':wscript.quit
'msgbox"Enabled:"&bEnabled':wscript.quit
'notsurewhy,butinvokeverbalwaysseemedtowork
'forenablebutnotdisable.
'
'savingareferencetotheappropriateverbobject
'andcallingtheDoItmethodalwaysseemstowork.
'
ifbEnabledthen
'oLanConnection.invokeverbsDisableVerb
oDisableVerb.DoIt
else
'oLanConnection.invokeverbsEnableVerb
oEnableVerb.DoIt
endif
'adjustthesleepdurationbelowasneeded...
'
'ifyoulettheoLanConnectiongooutofscope
'andbedestroyedtoosoon,theactionoftheverb
'maynottake...
'
wscript.sleep400
下面是应用这个技术的几段具体代码:
1、判断X和Y是否为同符号数值:
If(x<0Andy<0)Or(x>=0Andy>=0)Then...
'theoptimizedapproach
If(xXory)>=0Then
2、判断X、Y和Z是否都为正数
Ifx>=0Andy>=0Andz>=0Then...
'theoptimizedapproach
If(xOryOrz)>=0Then...
3、判断X、Y和Z是否都为负数
Ifx<0Andy<0Andz<0Then...
'theoptimizedapproach
If(xAndyAndz)<0Then...
4、判断X、Y和Z是否都为0
Ifx=0Andy=0Andz=0Then...
'theoptimizedapproach
If(xOryOrz)=0Then...
5、判断X、Y和Z是否都不为0
Ifx=0Andy=0Andz=0Then...
'theoptimizedapproach
If(xOryOrz)=0Then...
要使用这些来简单化一个复杂的表达式,必须要完全理解boolean型的操作原理
@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
只有在通过自动登陆读到密码时才有用用会封号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->特殊文件夹名称用于索引该集合以检索所需的特殊文件夹,文档中列出了下面的特殊文件夹:
AllUsersDesktop
AllUsersStartMenu
AllUsersPrograms
AllUsersStartup
Desktop
Favorites
Fonts
MyDocuments
NetHood
PrintHood
Programs
Recent
SendTo
StartMenu
Startup
Templates
不过今天在用OllyDbg调试VBS的时候,发现文档中少写了一个AppData文件夹,作文以记之。