一.学习Wscript
1.获取当前运行目录全路径
Wscript.ScriptFullName
2.获取Cscript.exe后面的参数
比如: Cscript test.vbs FileName=1.txt sn=1
获取参数FileName和SN:
Dim argItem, argFileName, argSN, aryArg
For each argItem in Wscript.Arguments
aryArg = Split(argItem, "=")
Select Case Ucase(aryArg(0))
Case "FILENAME"
argFileName = aryArg(1)
Case "SN"
argSN = aryArg(1)
End Select
Next
3.使用Wscript.shell组件开多个Dos运行窗口
Dim shell
Set shell = CreateObject("WScript.Shell")
Dim strCommand
strCommand = "Cscript " & wscript.ScriptFullName
shellResult = Shell.run(strCommand & " sn=" & i &" FileName=" & file ,1,False)
4. 在Dos窗口中打出信息, 用 Wscript.echo "要显示的信息"
5. Wscript.sleep(数字)
二. bat文件学习
1.用set 语句,要求用户输入参数
@echo off
set /p var=密码:
set /p user=用户:
cscript E:\checkpass.vbs %var% %user%
2.使用pause,脚本程序运行完会暂停,直到用户输入任意键