C# 运行 没有 .vbe 扩展名的 vbscript 编码文件,使用进程启动
C# run a vbscript encoded file without the .vbe extension using process start
我可以使用 process start 和 运行 没有 .vbs 扩展名的标准 vbscript(见下面我的代码)但是你如何 运行 使用 VBScript 编码器编码的 vbscript 文件不带 .vbe 扩展名的对象?
Process process = new Process();
process.StartInfo.FileName = @"wscript.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.Arguments = "//e:vbscript noExtensionFile";
process.Start();
假设您的问题是文件没有扩展名,您可以重命名它,您可以这样做:
string filename = ....
if (!Path.HasExtension(filename))
{
string t = Path.ChangeExtension(filename, ".vbe");
File.Move(filename, t);
filename = t;
}
// rest of your code
如果您尝试 运行 编码的 VBScript 文件,您需要 VBScript.Encode
引擎而不是 VBScript
引擎。尝试使用 //e:VBScript.Encode
作为 wscript
.
的第一个参数
我可以使用 process start 和 运行 没有 .vbs 扩展名的标准 vbscript(见下面我的代码)但是你如何 运行 使用 VBScript 编码器编码的 vbscript 文件不带 .vbe 扩展名的对象?
Process process = new Process();
process.StartInfo.FileName = @"wscript.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.Arguments = "//e:vbscript noExtensionFile";
process.Start();
假设您的问题是文件没有扩展名,您可以重命名它,您可以这样做:
string filename = ....
if (!Path.HasExtension(filename))
{
string t = Path.ChangeExtension(filename, ".vbe");
File.Move(filename, t);
filename = t;
}
// rest of your code
如果您尝试 运行 编码的 VBScript 文件,您需要 VBScript.Encode
引擎而不是 VBScript
引擎。尝试使用 //e:VBScript.Encode
作为 wscript
.