使用自定义颜色VB.NET打开批处理文件

使用自定义颜色VB.NET打开批处理文件,vb.net,batch-file,Vb.net,Batch File,我试图通过以下操作在自定义彩色cmd窗口中打开批处理文件: Public Class MyUtilities Shared Sub RunCommandCom(command As String, arguments As String, permanent As Boolean) Dim p As Process = New Process() Dim pi As ProcessStartInfo = New ProcessStartInfo()

我试图通过以下操作在自定义彩色cmd窗口中打开批处理文件:

Public Class MyUtilities
    Shared Sub RunCommandCom(command As String, arguments As String, permanent As Boolean)
        Dim p As Process = New Process()
        Dim pi As ProcessStartInfo = New ProcessStartInfo()
        pi.Arguments = " " + If(permanent = True, "/K", "/C") + " " + command + " " + arguments
        pi.FileName = "cmd.exe"
        p.StartInfo = pi
        p.Start()
    End Sub
End Class

       'Inside button click event
        Dim OpenCMD
        OpenCMD = CreateObject("wscript.shell")
        OpenCMD.run("cmd.exe & color 0e & " & My.Computer.FileSystem.SpecialDirectories.Desktop & "\test.bat " & "VARIABLE", vbNormalFocus)
但是,它一直说找不到该文件,当我从一开始就删除
cmd.exe&color 0e&“
时,它工作得非常好。由于我正在处理大量不同的批处理文件,并且不想更改批处理文件本身的颜色,如何更改它,使其在运行时成为特定的颜色?--批处理文件由多个不同的程序运行,因此我不想更改实际批处理文件本身的颜色,仅当从我的程序运行时。。。我也无法复制原始文件


如蒙指正,不胜感激

我不确定您为什么不在按钮单击事件中使用
RunCommandCom
。你只需要:

Dim cmd As String = IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "test.bat")
RunCommandCom("color 0e & " & cmd, "VARIABLE", False)
使用将为您处理路径分隔符(在本例中为“\”)


(测试为工作状态。)

可能与的重复,但我尝试使用&符号链接多个命令:/