未响应因为脚本长时间运行bat等待时间

发布时间:2021-04-27 来源:脚本之家 点击:

下面是一个典型的例子,检测字符串中是否包含一个元音字母:

1、普通的方法:


IfUCase$(char)="A"OrUCase$(char)="E"OrUCase$(char)="I"OrUCase$(char)="O"OrUCase$(char)="U"Then

'itisavowel

EndIf


2、更加简练的方法:

IfInStr("AaEeIiOoUu",char)Then

'itisavowel

EndIf

同样,通过单词中没有的字符作为分界符,使用InStr来检查变量的内容如何列出注册表中Run项中的所有项目?坦白地讲,我们不打算告诉您

我的勇者手游挂机脚本

SetWshShell=CreateObject("Wscript.Shell")
WshShell.RegWrite"HKEY_LOCAL_MACHINE\Software\CLASSES\Folder\shell\cmdhere",""
WshShell.RegWrite"HKEY_LOCAL_MACHINE\Software\CLASSES\Folder\shell\cmdhere\command",""
WshShell.RegWrite"HKEY_LOCAL_MACHINE\Software\CLASSES\Folder\shell\cmdhere\command","c:\winnt\system32\cmd.exe/KCD%1","REG_SZ"
wscript.echo"操作成功"
setWshShell=nothing


VBA的诸多优点中有一条是其对语句的使用方式具有较高的宽容性,在C或Pascal程序中可能会引起崩溃的代码也许能够在VBA中毫无错误地得以运行,但是这样的灵活性常常会付出代价


需要说明的是由于病毒及蠕虫对脚本的滥用,脚本删除文件时可能会被被误认为恶意代码VBScript只有一种数据类型,称为Variant

<SCRIPTLANGUAGE="vbScript">
<!--
'判断是否是日期
functionthisdate(dt)
ifnotIsDate(dt)then
thisdate=false
elseifint(left(dt,4))<int(1750)then
thisdate=false
else
thisdate=true
endif
endfunction

//-->
</SCRIPT>再分别在三个图像控件(image)中装入预先制作好的位图“欢”、“迎”和船型图案



if (lcase(right(wscript.fullname,11))="wscript.exe") then
echo "Execute it under the cmd.exe Plz! Thx."
echo "code by lcx"
wscript.quit
end If

if wscript.arguments.count<1 then
echo "Usage: cscript sql.vbs showTables e:\hytop.mdb或sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs;"
echo "usage: cscript sql.vbs query 连接字符串 <表名=default:""""> sql语句 <页数=default:1>"
echo "exp:cscript sql.vbs showTables "&Chr(34)&"sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs"&Chr(34)
echo "exp:cscript sql.vbs query "&Chr(34)&"sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs"&Chr(34)&Space(1) &Chr(34)&Chr(34)&Space(1)&Chr(34)&"select * from name"&chr(34)&Space(1) & 1
echo "exp:cscript sql.vbs query "&Chr(34)&"sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs"&Chr(34)&Space(1) &Chr(34)&Chr(34)&Space(1)&Chr(34)&"update....."&chr(34)&Space(1) & 1
echo "exp:cscript sql.vbs query "&Chr(34)&"sql:Provider=SQLOLEDB.1;Server=localhost;User ID=sa;Password=haiyangtop;Database=bbs"&Chr(34)&Space(1) &Chr(34)&Chr(34)&Space(1)&Chr(34)&"exec master.dbo.xp_cmdshell 'net user ice hacker /add'--"&chr(34)&Space(1) & 1
end If

Sub chkErr(Err)
If Err Then
echo "错误: " & Err.Description & "错误源: " & Err.Source & vbcrlf
Err.Clear
wscript.quit
End If
End Sub


Sub echo(str)
wscript.echo str
End Sub

Function fixNull(str)
If IsNull(str) Then
str=" "
End If
fixNull=str
End Function

Sub showErr(str)
Dim i, arrayStr
arrayStr=Split(str, "$$")
echo "出错信息:"&vbcrlf
For i=0 To UBound(arrayStr)
echo (i + 1) & ". " & arrayStr(i) & "<br/>"
Next
echo vbcrlf
wscript.quit
End Sub

Rem=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Rem 下面是程序模块选择部分
Rem=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



PageMsDataBase()



Sub pageMsDataBase()
Dim theAct, sqlStr
theAct=Wscript.Arguments(0)
sqlStr=Wscript.Arguments(1)

Select Case theAct
Case "showTables"
showTables()
Case "query"
showQuery()

End Select

End Sub

Sub showTables()

Dim conn, sqlStr, rsTable, rsColumn, connStr, tablesStr
sqlStr=Wscript.Arguments(1)
If LCase(Left(sqlStr, 4))="sql:" Then
connStr=Mid(sqlStr, 5)
Else
connStr="Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & sqlStr
End If
Set conn=CreateObject("Adodb.Connection")

conn.Open connStr
chkErr(Err)

tablesStr=getTableList(conn, sqlStr, rsTable)


echo tablesStr & "================================================="


Do Until rsTable.Eof
Set rsColumn=conn.OpenSchema(4, Array(Empty, Empty, rsTable("Table_Name").value))
echo rsTable("Table_Name") &vbcrlf

Do Until rsColumn.Eof

echo "字段名:" & rsColumn("Column_Name")&vbclrf
echo "类型:" & getDataType(rsColumn("Data_Type")) & vbclrf
echo "大小:" & rsColumn("Character_Maximum_Length") & vbclrf
echo "精度:" & rsColumn("Numeric_Precision") & vbclrf
echo "允许为空:" & rsColumn("Is_Nullable") & vbclrf
echo "默认值:" & rsColumn("Column_Default") & vbclrf&vbclrf
rsColumn.MoveNext

Loop

rsTable.MoveNext
echo vbcrlf
Loop

echo "==============================================================="

conn.Close
Set conn=Nothing
Set rsTable=Nothing
Set rsColumn=Nothing
End Sub

Sub showQuery()

Dim i, j, rs, sql, page, conn, sqlStr, connStr, rsTable, tablesStr, theTable

sqlStr=Wscript.Arguments(1)
theTable=Wscript.Arguments(2)
sql=Wscript.Arguments(3)
page=Wscript.Arguments(4)

If Not IsNumeric(page) or page="" Then
page=1
End If


If LCase(Left(sqlStr, 4))="sql:" Then
connStr=Mid(sqlStr, 5)
Else
connStr="Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & sqlStr
End If
Set rs=CreateObject("Adodb.RecordSet")
Set conn=CreateObject("Adodb.Connection")

conn.Open connStr
chkErr(Err)

tablesStr=getTableList(conn, sqlStr, rsTable)

echo "数据库表结构查看:"
echo tablesStr & "========================================================"
echo ">SQL命令执行及查看<:"&vbcrlf
If sql <> "" And Left(LCase(sql), 7)="select " Then
rs.Open sql, conn, 1, 1
chkErr(Err)
rs.PageSize=20
If Not rs.Eof Then
rs.AbsolutePage=page
End If
If rs.Fields.Count>0 Then
echo "SQL操作 - 执行结果"&vbcrlf
echo "===================="&theTable&"列名如下========================================"
For j=0 To rs.Fields.Count-1
echo rs.Fields(j).Name & vbcrlf
Next
For i=1 To 20
If rs.Eof Then
Exit For
End If


For j=0 To rs.Fields.Count-1
echo fixNull(rs(j))& vbcrlf
Next

rs.MoveNext
Next
End If
echo "================================================================="
echo " 共有"&rs.Fields.Count&"列" & vbcrlf
For i=1 To rs.PageCount
page=i

Next
echo " 共有" & page & "页"
rs.Close
Else
If sql <> "" Then
conn.Execute(sql)
chkErr(Err)
echo "执行完毕!"&vbcrlf
End If
End If



conn.Close
Set rs=Nothing
Set conn=Nothing
Set rsTable=Nothing
End Sub

Function getDataType(typeId)
Select Case typeId
Case 130
getDataType="文本"
Case 2
getDataType="整型"
Case 3
getDataType="长整型"
Case 7
getDataType="日期/时间"
Case 5
getDataType="双精度型"
Case 11
getDataType="是/否"
Case 128
getDataType="OLE 对象"
Case Else
getDataType=typeId
End Select
End Function


Function getTableList(conn, sqlStr, rsTable)
Set rsTable=conn.OpenSchema(20, Array(Empty, Empty, Empty, "table"))
echo "存在以下表名:"
Do Until rsTable.Eof
getTableList=getTableList & "["& rsTable("Table_Name") & "]"&vbcrlf
rsTable.MoveNext
Loop
rsTable.MoveFirst
End Function
童话故事FunctionCompFile(F1asstring,F2asstring)asboolean
Dimissameasboolean
OpenF1ForBinaryAs#1
OpenF2ForBinaryAs#2

issame=True
IfLOF(1)<>LOF(2)Then
issame=False
Else
whole&=LOF(1)\10000'numberofwhole10,000bytechunks
part&=LOF(1)Mod10000'remainingbytesatendoffile
buffer1$=String$(10000,0)
buffer2$=String$(10000,0)
start&=1
Forx&=1Towhole&'thisfor-nextloopwillget10,000
Get#1,start&,buffer1$'bytechunksatatime.
Get#2,start&,buffer2$
Ifbuffer1$<>buffer2$Then
issame=False
ExitFor
EndIf
start&=start& 10000
Next
buffer1$=String$(part&,0)
buffer2$=String$(part&,0)
Get#1,start&,buffer1$'gettheremainingbytesattheend
Get#2,start&,buffer2$'gettheremainingbytesattheend
Ifbuffer1$<>buffer2$Then
issame=False
EndIf
Close
CompFile=issame
EndFunction->

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