Project - Windows Forms (application)

Tell me how to properly hide the application if on the cmd command line write a command:

C:\app.exe /h 

Necessary in order to manage the application through a local network or through the Windows Scheduler using the application shortcut.

In addition, the following code in the application:

 public partial class Form1 : Form { private void Form1_VisibleChanged(object sender, EventArgs e) { string[] passedInArgs = Environment.GetCommandLineArgs(); foreach (string s in passedInArgs) { if (s.ToUpperInvariant() == "/H") { this.Hide(); RegistryKey key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\TEST002"); key.SetValue("000", "111"); key.Close(); this.Close(); } else { Registry.LocalMachine.DeleteSubKey("SOFTWARE\\TEST002", false); } } } public Form1() { InitializeComponent(); } } 
  • Do you write directly to HKLM? o_O - VladD
  • And what does "hide the application" mean? Hide an already running application, or launch a new instance of the application without displaying a window? - VladD
  • Hide - without window display (i.e. application form). So that when the task is executed in the scheduler, the application does not open to the user when entering the / h command - Vitokhv
  • NMD - did not help, is there really no code that ignores the appearance of the form window, if the application is accessed via cmd with the / h command - Vitokhv

0