Start a new topic
Answered

Hide External Window of Command Task

Hi,  I want to run a Command Task to connect to my VPN. It really annoys me to see the CMD Window after connecting to an RDP bc my VPN-Connections takes like 20 sec to complete… Is there any way of setting the arguments such as I don't have to see the CMD Window? I tried /min and all that stuff, but could not seem to get it to work. I would really appreciate if anyone has a nice and clean way of doing this without calling a 2nd Script. 


Best Answer

I found a Solution, just compile your own windows forms and call the *.bat in the load function. Example Code


      

    private void Form1_Load(object sender, EventArgs e)
        {
            string[] args = Environment.GetCommandLineArgs();
            this.WindowState = FormWindowState.Minimized;
            Process process = new Process();
            process.StartInfo.FileName = "Your_Bat_Name.bat";
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.StartInfo.Arguments = args[1]; // arg[0] is the directory path 
            process.Start();
            process.WaitForExit();
            this.Close(); 

        }

      


I forgot to mention that I am running a *.Bat as my Command-Task 

Hi Tom,


unfortunately, that's not possible within Royal TS, but could use a workaround, like SilentCMD ( https://github.com/stbrenner/SilentCMD ), or try out one of the options mentioned here:

https://www.robvanderwoude.com/battech_hideconsole.php


Sorry to be the bearer of bad news!


Best regards,

Christoph

Answer

I found a Solution, just compile your own windows forms and call the *.bat in the load function. Example Code


      

    private void Form1_Load(object sender, EventArgs e)
        {
            string[] args = Environment.GetCommandLineArgs();
            this.WindowState = FormWindowState.Minimized;
            Process process = new Process();
            process.StartInfo.FileName = "Your_Bat_Name.bat";
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.StartInfo.Arguments = args[1]; // arg[0] is the directory path 
            process.Start();
            process.WaitForExit();
            this.Close(); 

        }

      

Hi Tom,


that's great news, thanks for the follow-up.

If you need anything else, let us know, otherwise have a nice day!


Best regards,

Christoph

Login or Signup to post a comment