Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,

I am trying to start notepad.exe in hidden mode like below is the code which i have written:-

C#
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "notepad.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = @"C:\Users\Sujeet\Documents\test.txt";
}
catch
{
//
}
but the problem is process(i.e. notepad.exe) gets successfully started but startInfo.WindowStyle = ProcessWindowStyle.Hidden is not working. I have surfed net for this problem but wasnot able to get the proper solution.

Please help me !!! Thanks in Advance!
Posted
Updated 7-May-15 23:36pm
v2
Comments
Thanks7872 8-May-15 2:46am    
Hidden notepad? I've never heard of such thing before. What will you do with that BTW?
Sergey Alexandrovich Kryukov 8-May-15 2:48am    
Just the nonsense. I would suggest to remove this post and go ahead.
—SA
Thanks7872 8-May-15 2:57am    
I would have ignored this but thought we can recommend something if he explains what he is upto.

Congratulations..! Keep up the good work.! :thumbsup:
Sergey Alexandrovich Kryukov 8-May-15 3:00am    
Thank you, Rohan.
—SA
[no name] 8-May-15 4:41am    
If its of no sense then why you have wasted your time to comment.

1 solution

C#
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

then simply call it like this:

C#
Process p = new Process();
startInfo.FileName = "notepad.exe";
p.Start();
ShowWindow(p.MainWindowHandle, 0);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900