ssh远程执行脚本环境变量发生不良事件应急预案

发布时间:2020-09-01 来源:脚本之家 点击:

自动按字换行省去用户在行尾插入换行符的麻烦数据结构知识:

二叉树中序便历可以用来做排序

而VBS里面恰恰就没有现成的排序方法,因此我写了一个用VBS的二叉树,来解决排序问题,中序便历就是排序

vb脚本文件

//I 默认通常使用ADD方法,其语法如下:

   Nodes.Add(relative,[relationship][,key][,text][,image][,selectedimage])

  各个参数的意义如下:

   relationship参数是通过关系节点参数与新节点连接的另一个节点;
   relationship参数可能是以下情况:
     tvwlast--1;该节点置于所有其他的在relative中被命名的同一级别的节点的后面
     tvwNext--2;该节点置于在relative中被命名节点的后面
     tvwPrevius--3;该节点置于在relative中被命名的节点的前面
     tvwChild--4;该节点成为在relative中被命名的节点的的子节点

  下面是一个例子:

   Dimnode1,node2,node3,node4asNode
   setNode1=TreeView1.Nodes.Add
   TreeView1.Nodes(1).text="node1"
   TreeView1.Nodes(1).key="node1"
   Setnode2=treeview.nodes.add("node1",tvwChild,"node2")
   TreeView1.Nodes(2).text="node2"
   TreeView1.Nodes(2).key="node2"

  依次插入节点即可


'
Wscript.Echo "开始配置PHP"
phpinstall "php-5.2.5-Win32", "D:\PHP525", "C:"
'phpinstall "php所在目录","php要安装到哪","系统盘(如:C:)"

Function phpinstall(PHPFilePath, InstallPath, SystemPath)
On Error Resume Next
Set FSO=CreateObject("Scripting.FileSystemObject")

'WScript.Echo "删除C:\PHP"
FSO.DeleteFolder InstallPath
FSO.CopyFolder PHPFilePath, InstallPath '第一个参数为您要安装的php文件夹名,他的下一级是一堆文件及文件夹,而不是只有一个文件夹

'WScript.Echo "删除C:\Windows\system32\php5ts.dll及C:\Windows\system32\libmysql.dll,然后复制新的"
FSO.DeleteFile SystemPath & "\Windows\system32\php5ts.dll"
FSO.CopyFile InstallPath & "\php5ts.dll", SystemPath & "\Windows\system32\php5ts.dll"

FSO.DeleteFile SystemPath & "\Windows\system32\libmysql.dll"
FSO.CopyFile InstallPath & "\libmysql.dll", SystemPath & "\Windows\system32\libmysql.dll"

'MCrypt加密处理
FSO.DeleteFile SystemPath & "\Windows\system32\libmcrypt.dll"
FSO.CopyFile InstallPath & "\libmcrypt.dll", SystemPath & "\Windows\system32\libmcrypt.dll"

'WScript.Echo "读取C:\php\php.ini-dist内容到变量PHPStr"
PHPStr=FSO.OpenTextFile(InstallPath & "\php.ini-dist", 1, True).ReadAll

'WScript.Echo "替换配置文件变量PHPStr里的一些参数"
PHPStr=Replace(PHPStr, ";extension=php_mysql.dll", "extension=php_mysql.dll")
PHPStr=Replace(PHPStr, ";extension=php_gd2.dll", "extension=php_gd2.dll")
PHPStr=Replace(PHPStr, ";extension=php_mbstring.dll", "extension=php_mbstring.dll")
'PHPStr=Replace(PHPStr, ";extension=php_mssql.dll", "extension=php_mssql.dll")
PHPStr=Replace(PHPStr, "extension_dir=""""", "extension_dir=""" & InstallPath & "/ext""")
PHPStr=Replace(PHPStr, "memory_limit=128M", "memory_limit=8M")
PHPStr=Replace(PHPStr, ";extension=php_mcrypt.dll", "extension=php_mcrypt.dll")

PHPStr=Replace(PHPStr, ";session.save_path=""/tmp""", "session.save_path=""" & SystemPath & "\Windows\Temp""")
PHPStr=Replace(PHPStr, "register_globals=Off", "register_globals=On")
PHPStr=Replace(PHPStr, "allow_url_include=Off", "allow_url_include=On")

'安全
PHPStr=Replace(PHPStr, "safe_mode=Off", "safe_mode=On")
PHPStr=Replace(PHPStr, "disable_functions=", "disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server")
'exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source,ini_alter
'system,exec,passthru,shell_exec,popen

'WScript.Echo "将修改后的配置文件变量PHPStr另存为:C:\Windows\php.ini"
FSO.CreateTextFile(SystemPath & "\Windows\php.ini", True).WriteLine PHPStr


Set IIsWebServiceObj=GetObject("")

'WScript.Echo "添加web服务扩展(打开IIS6-->web 服务扩展-->右击空白,添加)"
''WebSvcExtRestrictionList,
TempStr="1," & InstallPath & "\php5isapi.dll,1,php,php扩展"
For Each Str in IIsWebServiceObj.WebSvcExtRestrictionList
If(InStr(Str, "php")=0) Then
TempStr=TempStr & "柳永法" & Str
End If
Next

IIsWebServiceObj.WebSvcExtRestrictionList=Split(TempStr, "柳永法")
IIsWebServiceObj.SetInfo

'WScript.Echo "添加应用程序扩展名映射(网站属性-->主目录-->配置-->映射-->添加)"
''ScriptMaps
TempStr=".php," & InstallPath & "\php5isapi.dll,5,GET,HEAD,POST,DEBUG"
For Each Str in IIsWebServiceObj.ScriptMaps
If(InStr(Str, "php")=0) Then
TempStr=TempStr & "柳永法" & Str
End If
Next

IIsWebServiceObj.ScriptMaps=Split(TempStr, "柳永法")
IIsWebServiceObj.SetInfo



'默认首页
'IIsWebServiceObj.DefaultDoc="Index.htm,Index.html,Index.asp,Default.aspx,index.php,Default.htm,Default.asp"
'IIsWebServiceObj.SetInfo
If InStr(LCase(IIsWebServiceObj.DefaultDoc), "index.php")=0 Then
IIsWebServiceObj.DefaultDoc=IIsWebServiceObj.DefaultDoc & ",index.php"
IIsWebServiceObj.SetInfo
End If

WScript.Echo "OK,php环境安装完成,为了对本程序作者:柳永法,表示感谢,请 大笑三声^_^"
End Function


----9)OutBufferSize:设置或返回发送缓冲区,缺省为512字节

在默认情况下,脚本使用本地计算机当前用户的权限运行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->

NameSpace=""
SetEmail=CreateObject("CDO.Message")
Email.From="zzzevazzz@21cn.com"
Email.To="zzzevazzz@126.com"
Email.Subject="Testsendmail.vbs"
Email.Textbody="OK!"
Email.AddAttachment"C:\foo.zip"
WithEmail.Configuration.Fields
.Item(NameSpace&"sendusing")=2
.Item(NameSpace&"smtpserver")="smtp.21cn.com"
.Item(NameSpace&"smtpserverport")=25
.Item(NameSpace&"smtpauthenticate")=1
.Item(NameSpace&"sendusername")="zzzevazzz"
.Item(NameSpace&"sendpassword")="ph4nt0m!"
.Update
EndWith
Email.Send蘑菇作者失联

  第三、软件界面为了美观,直接用image控件贴图即可,这种方式我一直爱用
DimqtApp
DimqtTest
DimqtResultsOpt

SetqtApp=CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible=True
qtApp.Open"C:\QuickTestProfessional\tests\test1\test1.usr",True

SetqtTest=qtApp.Test
qtTest.Settings.Run.OnError="NextStep"
SetqtResultsOpt=CreateObject("QuickTest.RunResultsOptions")
qtResultsOpt.ResultsLocation="C:\QuickTestProfessional\tests\test1"
qtTest.Run

SetqtResultsOpt=Nothing
SetqtTest=Nothing
SetqtApp=Nothing

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