●强制用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脚本的更多相关文章

  1. VB脚本调用exe应用程序并传递参数

    VB脚本调用应用程序,并传递参数给exe应用程序: Private Sub CommandButton1_Click() Dim a a = Shell("D:\\ExperimentLin ...

  2. Windows 用bat脚本带配置启动redis,并用vb脚本使其在后台运行。

    最近,在Windows上用开发PHP程序,需要用到Redis,每天要打开一个运行redis-server.exe的窗口这样比较烦,因为窗口就一直打开着,不能关闭. 所以就想着通过写脚本的方式,让他在后 ...

  3. 使用Runtime.getRuntime().exec()在java中调用python脚本

    举例有一个Python脚本叫test.py,现在想要在Java里调用这个脚本.假定这个test.py里面使用了拓展的包,使得pythoninterpreter之类内嵌的编译器无法使用,那么只能采用ja ...

  4. linux+php+apache web调用python脚本权限问题解决方案

    lamp : linux + apache + mysql + php 在上篇随笔中linux+php+apache调用python脚本时出现的问题的根本原因是:apache运行时使用的apache用 ...

  5. linux+php+apache web调用python脚本权限问题

    lamp : linux + apache + mysql + php 在近期项目中使用 linux + apache + php调用python脚本是出现以下权限问题: build/bdist.li ...

  6. 在<a></a>标签中调用javascript脚本

    有时候,我们点击了<a></a>标签(除了跳转到指定链接外)想要它调用某个方法,及调用javascript脚本,该如何做: 方法1:<a href="javas ...

  7. 【原】Gradle调用shell脚本和python脚本并传参

    最近由于项目自动化构建的需要,研究了下gradle调用脚本并传参的用法,在此作个总结. Pre build.gradle中定义了$jenkinsJobName $jenkinsBuild两个Jenki ...

  8. 调用shell脚本,IP处理

    //调用shell脚本,IP处理 package com.letv.sdns.web.utils; import org.slf4j.Logger; import org.slf4j.LoggerFa ...

  9. PHP 调用Python脚本

    上次做用户反馈自动翻译,写了个python脚本,将日文的用户反馈翻译成中文,效果虽然可以,但其它不懂python的童鞋就没法使用了,所以搭了个web服务,让其他人可以通过网页访问查询.使用的是apac ...

随机推荐

  1. jQuery 中的 39 个技巧【申明:来源于网络】

    jQuery 中的 39 个技巧[申明:来源于网络] 地址:http://blog.csdn.net/zhongqi2513/article/details/53704812?ref=myread

  2. Android100【申明:来源于网络】

    Android100[申明:来源于网络] 地址:http://www.android100.org/html/201406/11/23770.html

  3. Codeforces 584 - A/B/C/D/E - (Done)

    链接:https://codeforces.com/contest/584 A - Olesya and Rodion - [水] 题解:注意到 $t$ 的范围是 $[2,10]$,对于位数小于 $2 ...

  4. POJ 2187 - Beauty Contest - [凸包+旋转卡壳法][凸包的直径]

    题目链接:http://poj.org/problem?id=2187 Time Limit: 3000MS Memory Limit: 65536K Description Bessie, Farm ...

  5. vue问题大全

    什么是 mvvm? MVVM 是 Model-View-ViewModel 的缩写.mvvm 是一种设计思想.Model 层代表数据模型,也可以在 Model 中定义数据修改和操作的业务逻辑:View ...

  6. 关于 spring MVC 配置自动扫描中 use-default-filters 属性

    1.springMVC 设置扫描 Bean 的两种常见写法 1.1.先看第一种常见的配置:默认 <!-- 配置Controller扫描 --> <context:component- ...

  7. python基础之 编码进阶,文件操作和深浅copy

    1.编码的进阶 字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码.即先将其他编码的字符串解码(decode)成unicode,再从unic ...

  8. 竖倾斜ScrollView

    using UnityEngine; using UnityEngine.EventSystems; public class ObliqueScroll : MonoBehaviour,IDragH ...

  9. docker构建本地仓库后,无法登陆解决办法(CentOS/Ubuntu)

    docker版本为:Server Version: 1.12.6 从dockerhub上下载最新的registry镜像. 首先.构建registry 1.下载registry镜像 docker pul ...

  10. GreenDao 使用和数据库升级

    1使用方法 一.添加依赖 在bulid.gradle文件下的dependencies下添加所需依赖   compile 'org.greenrobot:greendao:3.2.2' // add l ...