如何嵌入VBS在C#和运行呢? [英] How to embed VBS in C# and run it?

查看:299
本文介绍了如何嵌入VBS在C#和运行呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有工作的罚款一个VBScript。我有一个可以与CSCRIPT程序运行VBScript C#程序。



我想要做的就是嵌入VBS在C#中的EXE所以它是一个单一的文件,能够运行VBS文件。有什么办法,我通过嵌入的VBScript文件为Cscript作为参数或一些其他的方式来运行嵌入式VBS文件?


解决方案

 键入scriptType = Type.GetTypeFromCLSID(Guid.Parse(0E59F1D5-1FBE-11D0-8FF2-00A0D10038BC)); 

动态的obj = Activator.CreateInstance(scriptType,FALSE);
obj.Language =VBSCRIPT;
字符串的VBScript =MSGBOX(\test\);
obj.Eval(VBScript)的;


I have a VBScript that's working fine. I have a C# program that can run the VBScript with the cscript program.

What I want to do is embed the VBS in a C# exe so it is one single file and be able to run the VBS file. Is there any way for me to pass the embedded VBScript file to cscript as an argument or some other way to run an embedded VBS file?

解决方案

Type scriptType = Type.GetTypeFromCLSID(Guid.Parse("0E59F1D5-1FBE-11D0-8FF2-00A0D10038BC"));

dynamic obj = Activator.CreateInstance(scriptType, false);
obj.Language = "vbscript";
string vbscript = "msgbox(\"test\")";
obj.Eval(vbscript);

这篇关于如何嵌入VBS在C#和运行呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆