http://blog.theopensourceu.com/2009/05/debug-vbscript-with-visual-studio/

For a project that I work on at at my primary employer, we use VBScript inside of DTS packages. Until this project, I’ve not had too much experience with VBScript. What I’ve found most frustrating about the language is the inability to step though the code… until a recent discovery. I’ve found that if I save the target code to my local machine as a VBS file and execute it with WScript.exe, I can attach a debugger to it.

I’ve discovered this by poking around and I don’t know too much about WScript.exe. I’m sure if you Google it, you can find more about it.

For this to work, you’ll need a copy of Visual Studio installed. I am not sure if any of the express editions will work. Drop a line in the comments if you find it will. As a quick walk though:

  1. Save your code as a VBS file. Don’t forget to call Main (or your main) function as wscript won’t automatically call main.
  2. Open a command prompt.
  3. Navigate to the location of the file.
  4. Type: WScript.exe FileName.vbs //D //X
  5. You should be prompted to select a debugger, select a new instance of either Visual Studio 2003, 2005 or 2008.
  6. Visual studio will open up and break at the very first line.
  7. Step though the code.

For an example, save the following as “Example.vbs” on your desktop.

MsgBox "Starting Script!"
Dim i : i = 0
Const C_Max = 100
Dim sPrimeNumberList : sPrimeNumberList = "Prime Numbers: " & vbCrLf
For i = 0 to C_Max
If IsNumberPrimeNumber(i) ThensPrimeNumberList = sPrimeNumberList & cStr(i) & ", "
EndIf
Next
MsgBox sPrimeNumberList
MsgBox "Script Completed."PublicFunction IsNumberPrimeNumber(ByVal iNumber)
Dim bIsPrime : bIsPrime = True
For j = 2 To iNumber\2bIsPrime = iNumber Mod j > 0
IfNot bIsPrime ThenExitFor
Next
IsNumberPrimeNumber = bIsPrime
EndFunction

Open a command prompt and navigate to your desktop:

Command Prompt for DebuggingVBScript from Visual Studio

Once there, type in the following:

1
wscript Example.vbs //D //X

You should then be presented with a dialog similar to the following:

Visual StudioDebuggingVBScript

Once you make a selection, you should get something like the following:

DebuggingVBScript from Visual Studio

From here, I’ll assume you are familiar enough with Visual Studio to play with the debugger and learn how it works. When debuggingVBScript, I’ve found that you don’t have all the options that you might be used to such as Step In To, but for me simply having this much is a life saver.

To get around the step-in-to thing, I simply use Run to Cursor. It works like a charm.

Update: I just found that (at least on this computer) and in Visual Studio 2003, I have all my standard code-stepping buttons available. I’m not sure why on my work computer I only have Step-Over but either way, this is still a life saver.

转载于:https://www.cnblogs.com/pegasus923/archive/2011/01/12/1933731.html

[ZZ]Debug VBScript with Visual Studio相关推荐

  1. Visual Studio调试/加载速度很慢

    本文翻译自:Visual Studio debugging/loading very slow I'm at wits end. 我的智慧结束了. Visual Studio is typically ...

  2. vs2015 支持Android arm neon Introducing Visual Studio’s Emulator for Android

    visual studio 2015支持Android开发了. Microsoft released Visual Studio 2015 Preview this week and with it ...

  3. Visual Studio Debug 教程 之 入门

    在过去,我已经写过好几篇关于调试 / debug / 解 Bug 的文章,但都是从宏观的角度上去讲的,并没有针对哪种工具做具体深入的剖析. 工欲善其事,必先利其器,一个强大的调试工具可以帮助我们快速的 ...

  4. Visual Studio 中Debug模式和Release模式的区别

    引用文章:Visual Studio中Debug和Release的区别 https://www.cnblogs.com/darrenji/p/3907004.html

  5. 用Visual Studio Code Debug世界上最好的语言(Mac篇)

    用Visual Studio Code Debug世界上最好的语言(Mac篇) 首先,你要有台Macbook Pro,接着才继续看这个教程. PS:Windows用户看这里用Visual Studio ...

  6. visual studio 调试 定义debug常量_有趣的阅读 12个提高生产力的Visual Studio调试技巧...

    以前因为工作的关系,接触过不少程序员同行,发现很多同学对所谓的小技巧tips感兴趣.本文就是一篇很有趣的文章,总结介绍了12个关于"宇宙第一IDE"-- Visual Studio ...

  7. Visual Studio中Debug和Release的区别

    在Visual Studio中,生成应用程序的时候有2种模式:Debug和Release.两者之间如何取舍呢? 假设有这么简单的一段代码,在主程序中调用方法M1,M1方法调用M2方法,M2方法调用M3 ...

  8. Visual Studio在Release模式下开启debug调试,编译器提示变量已被优化掉,因而不可用

    系列文章目录 文章目录 系列文章目录 前言 一.解决办法 1.修改工程属性 参考 前言 我们在编写代码的时候,如果用到别人的库,而别人只提供了release版本,所有我们也只能生成release版本的 ...

  9. 用Visual Studio Code Debug世界上最好的语言

    前言 这阵子因缘巧合接手了一个辣鸡项目,是用世界上最好的拍黄片写的,项目基本是另一个小伙伴在撸码,我就兼职打杂和发布做点运维的工作. 然后昨天项目上了测试版之后,一用起来Error满天飞了.让小伙伴查 ...

最新文章

  1. SQL查询效率注意事项
  2. android fragment 菜单栏,android UI:底部菜单栏的学习与制作——Fragment碎片一
  3. exchange命令整理
  4. 阐述计算机网络的作用答案,计算机网络习题及答案(50页)-原创力文档
  5. winshark重要数据结构
  6. Taro+react开发(65):h5全局重置背景样式
  7. 刀片服务器改台式电脑_服务器到底是个什么东东?跟电脑有啥区别?电脑知识学习!...
  8. 【推荐实践】Hulu-视频理解在个性化推荐与内容发现中的应用.pdf(附下载链接)...
  9. 360无痕浏览器_功能强大好用的浏览器
  10. CRMEB商城打通版 v3.0发布
  11. 2024考研《艺术学概论》彭吉象|复习笔记(上篇)(1-6章)
  12. 【年度总结】继往开来:回首不靠谱的2021,希冀靠谱的2022
  13. 1063: 最大公约与最小公倍
  14. 从 QCon 旧金山 2012中学到的关键经验和教训
  15. 基于JAVA微博网站计算机毕业设计源码+系统+mysql数据库+lw文档+部署
  16. springboot 相同类名但不同包,报错non-compatible bean definition of same name and class
  17. Ajax入门介绍篇:Ajax开发基础
  18. Java中高级核心知识全面解析(3),美团Java面试算法题
  19. 鸿蒙源码导读-01:蓝海与红海
  20. mn数组计算java陆地和海洋01,2008年高三地理一轮复习精讲精练四—陆地和海洋

热门文章

  1. python基础15 ---面像对象的程序设计
  2. Visual Studio 2017 调试 windows server 2016 Docker Container
  3. assign与weak区别(面试)
  4. VmWare下安装CentOS6
  5. ADO.NET中的五个主要对象
  6. MFC中创建线程实例
  7. IOS15仿微信我的页面
  8. 驱动人生2008_驱动人生致敬深圳经济特区建立四十周年!
  9. css3怎么设置logo,纯CSS3实现的LOGO标志 ABN AMRO CSS3 logo
  10. osg中实现HUDAxis功能