使用Wscript/cscript调用VB脚本
●强制用Wscript.exe执行
SET Wshell=CreateObject("Wscript.Shell")
if lcase(right(Wscript.fullName,11)) = "cscript.exe" then
Wshell.run "wscript.exe //nologo " & chr(34) & wscript.scriptfullname & chr(34)
Wscript.quit
else
Wscript.echo "执行代码写在此处"
end if
●强制用Cscript.exe执行:
SET Wshell=CreateObject("Wscript.Shell")
if lcase(right(Wscript.fullName,11)) = "wscript.exe" then
Wshell.run "cmd /k cscript.exe //nologo " & chr(34) & wscript.scriptfullname & chr(34)
Wscript.quit
else
Wscript.echo "执行代码写在此处"
end if
●调试:
在cmd窗口输入:
Wscript.exe /X test.vbs
会弹出visual studio调试窗口,即可完成调试。
或者:
利用消息框调试:
WScript.Sleep(10000) //sleep 10秒
WScript.Echo "Success" //在wscript.exe下显示消息弹框
Wshell.Popup "aaabbb" //在cscript.exe下显示消息弹框
●bat脚本调用vb方式
cscript //logo c:\"test scripts"\test.vbs
cscript //nologo c:\"test scripts"\test.vbs
cmd /k表示 执行完后面的命令时,窗口保留,/c表示窗口关闭
/后面表示选项,常用用下列几种,你可以在命令行下输入 cmd /?看到:
/C 执行字符串指定的命令然后终断
/K 执行字符串指定的命令但保留
/S 在 /C 或 /K 后修改字符串处理(见下)
/Q 关闭回应
/D 从注册表中停用执行 AutoRun 命令(见下)
/A 使向内部管道或文件命令的输出成为 ANSI
/U 使向内部管道或文件命令的输出成为 Unicode
●VBScript无效字符800A0408编译错误
①在记事本中打开.vbs
②转到文件并“另存为”
③在文件名框下面,编码下拉菜单选择ANSI。
//强制使用cscript.exe执行vb脚本。
Dim strArgs, strCmd, strEngine, i, objDebug, wshShell
Set wshShell = CreateObject( "WScript.Shell" )
strEngine = UCase( Right( WScript.FullName, 12 ) ) If strEngine <> "\CSCRIPT.EXE" Then
' Recreate the list of command line arguments
strArgs = ""
If WScript.Arguments.Count > 0 Then
For i = 0 To WScript.Arguments.Count - 1
strArgs = strArgs & " " & WScript.Arguments(i)
Next
End If ' Create the complete command line to rerun this script in CSCRIPT
strCmd = "CSCRIPT.EXE //NoLogo """ & WScript.ScriptFullName & """" & strArgs ' Rerun the script in CSCRIPT
Set objDebug = wshShell.Exec( strCmd ) ' Wait until the script exits
Do While objDebug.Status = 0
WScript.Sleep 100
Loop ' Exit with CSCRIPT's return code
WScript.Quit objDebug.ExitCode
End If //强制使用cscript.exe执行vb脚本。 If (right(Ucase(WScript.FullName),11)="WSCRIPT.EXE") Then
Dim WshShell,args,objArgs,I
Set WshShell = CreateObject("WScript.Shell")
args=""
If Wscript.Arguments.Count > 0 Then
Set objArgs = WScript.Arguments
For I = 0 to objArgs.Count - 1
args = args & " " & objArgs(I)
Next
End If
Set objDebug = WshShell.Exec ( "cscript.exe /NoLogo """ & Wscript.ScriptFullName & """" & args ) ' Wait until the script exits
Do While objDebug.Status = 0
WScript.Sleep 100
Loop ' Exit with CSCRIPT's return code
WScript.Quit objDebug.ExitCode
End If
使用Wscript/cscript调用VB脚本的更多相关文章
- VB脚本调用exe应用程序并传递参数
VB脚本调用应用程序,并传递参数给exe应用程序: Private Sub CommandButton1_Click() Dim a a = Shell("D:\\ExperimentLin ...
- Windows 用bat脚本带配置启动redis,并用vb脚本使其在后台运行。
最近,在Windows上用开发PHP程序,需要用到Redis,每天要打开一个运行redis-server.exe的窗口这样比较烦,因为窗口就一直打开着,不能关闭. 所以就想着通过写脚本的方式,让他在后 ...
- 使用Runtime.getRuntime().exec()在java中调用python脚本
举例有一个Python脚本叫test.py,现在想要在Java里调用这个脚本.假定这个test.py里面使用了拓展的包,使得pythoninterpreter之类内嵌的编译器无法使用,那么只能采用ja ...
- linux+php+apache web调用python脚本权限问题解决方案
lamp : linux + apache + mysql + php 在上篇随笔中linux+php+apache调用python脚本时出现的问题的根本原因是:apache运行时使用的apache用 ...
- linux+php+apache web调用python脚本权限问题
lamp : linux + apache + mysql + php 在近期项目中使用 linux + apache + php调用python脚本是出现以下权限问题: build/bdist.li ...
- 在<a></a>标签中调用javascript脚本
有时候,我们点击了<a></a>标签(除了跳转到指定链接外)想要它调用某个方法,及调用javascript脚本,该如何做: 方法1:<a href="javas ...
- 【原】Gradle调用shell脚本和python脚本并传参
最近由于项目自动化构建的需要,研究了下gradle调用脚本并传参的用法,在此作个总结. Pre build.gradle中定义了$jenkinsJobName $jenkinsBuild两个Jenki ...
- 调用shell脚本,IP处理
//调用shell脚本,IP处理 package com.letv.sdns.web.utils; import org.slf4j.Logger; import org.slf4j.LoggerFa ...
- PHP 调用Python脚本
上次做用户反馈自动翻译,写了个python脚本,将日文的用户反馈翻译成中文,效果虽然可以,但其它不懂python的童鞋就没法使用了,所以搭了个web服务,让其他人可以通过网页访问查询.使用的是apac ...
随机推荐
- 实体框架—Entity Framework
简称EF,是微软以ADO.NET为基础所发展出来的对象关系对应(ORM)解决方案. EF就是用来处理数据的,与数据库打交道.但是底层还是用到了ADO.NET的那一套东西. 为什么叫对象关系对应解决方案 ...
- The way to unwind the stack on Linux EABI
I. probe the stack frame structure The original idea is to unwind the function call stack according ...
- Qt自定义界面
https://blog.csdn.net/zhangxiaoyu_sy/article/details/78925221
- 【Python全栈】HTML <!--...--> 注释 、CSS/JS //注释 和 /*.....*/ 注释
HTML <!--...--> 注释 .CSS/JS //注释 和 /*.....*/ 注释 <!-- -->是HTML的注释标签,使用 < 和 > 是符合HTML ...
- CMake和Linux编程:find_package的使用
1.第一个CMake例子 在 t1 目录建立 main.c 和 CMakeLists.txt(注意文件名大小写): main.c 文件内容: //main.c #include <stdio.h ...
- [js]js设计模式-构造函数模式
构造函数模式 function WriteJsPerson(name,age) { this.name=name; //不用手动创建obj this.age = age; this.writeJs=f ...
- 公网k8s
dm :32750/swagger/ 统一在 cd /opt/iot 删除容器,自动创建容器 dm 更新dm和acl包 dm源文件chart包 cd /var/lib/helmrepo/ h ...
- 二、认识Xcode(第一个工程:Hello world)
到一个未知的世界去冒险,怎么可以不熟悉自己的武器装备呢?况且我们现在也就Xcode这一样装备,攻击防御全靠它,要是关键时刻使不出技能,那不gg了? 所以接下来我们会大致介绍Xcode的常用界面,并在最 ...
- ionic3 在ios9.0 系统下 会出现ReferenceError:Can't find variable:Intl 错误提示
ionic3 框架开发app 在ios 9.0版本中 ReferenceError:Can't find variable:Intl 错误提示: 在index.html 文件中添加 <scri ...
- 用python写多线程
import threading #首先导入threading 模块,这是使用多线程的前提 from time import ctime,sleep def music(func): ): print ...