473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Hiding the Process Window when running as a different user

I need to hide the new window started from the code below. If I run as is,
the window is visible. If I comment out the code that sets a different user,
domain, and password the window is hidden as desired. Does anyone know if
there is a known issue with hiding a process window when you run it as a
different user? Do you have any suggestions to work around this problem?
Thank you.

Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/C time /T";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.Domain = CurrentAdmin.Domain;
proc.StartInfo.UserName = CurrentAdmin.UserID;
proc.StartInfo.Password = CurrentAdmin.Password;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
StreamReader myOutput = proc.StandardOutput;

proc.WaitForExit();

while (myOutput.EndOfStream == false)
{
string Inline;
Inline = myOutput.ReadLine();
Response = Response + Inline + Environment.NewLine;
}
MessageBox.Show(Response);

Sep 5 '08 #1
4 3969
Bumping this one once. I really would like to get a professional opinion on
how to do this, please.

"Huey" wrote:
I need to hide the new window started from the code below. If I run as is,
the window is visible. If I comment out the code that sets a different user,
domain, and password the window is hidden as desired. Does anyone know if
there is a known issue with hiding a process window when you run it as a
different user? Do you have any suggestions to work around this problem?
Thank you.

Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/C time /T";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.Domain = CurrentAdmin.Domain;
proc.StartInfo.UserName = CurrentAdmin.UserID;
proc.StartInfo.Password = CurrentAdmin.Password;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
StreamReader myOutput = proc.StandardOutput;

proc.WaitForExit();

while (myOutput.EndOfStream == false)
{
string Inline;
Inline = myOutput.ReadLine();
Response = Response + Inline + Environment.NewLine;
}
MessageBox.Show(Response);
Oct 23 '08 #2
Quote from MSDN for the Process.StartInfo Property:

"If you call the Start(ProcessStartInfo) method with the
ProcessStartInfo..::.UserName and ProcessStartInfo..::.Password properties
set, the unmanaged CreateProcessWithLogonW function is called, which starts
the process in a new window even if the CreateNoWindow property value is
true or the WindowStyle property value is Hidden."

"Huey" <Hu**@discussions.microsoft.comwrote in message
news:6D**********************************@microsof t.com...
Bumping this one once. I really would like to get a professional opinion
on
how to do this, please.

"Huey" wrote:
>I need to hide the new window started from the code below. If I run as
is,
the window is visible. If I comment out the code that sets a different
user,
domain, and password the window is hidden as desired. Does anyone know
if
there is a known issue with hiding a process window when you run it as a
different user? Do you have any suggestions to work around this problem?
Thank you.

Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/C time /T";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.Domain = CurrentAdmin.Domain;
proc.StartInfo.UserName = CurrentAdmin.UserID;
proc.StartInfo.Password = CurrentAdmin.Password;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
StreamReader myOutput = proc.StandardOutput;

proc.WaitForExit();

while (myOutput.EndOfStream == false)
{
string Inline;
Inline = myOutput.ReadLine();
Response = Response + Inline + Environment.NewLine;
}
MessageBox.Show(Response);

Oct 23 '08 #3
Thanks! I feel sufficiently stupid now. :]

"Andrew" wrote:
Quote from MSDN for the Process.StartInfo Property:

"If you call the Start(ProcessStartInfo) method with the
ProcessStartInfo..::.UserName and ProcessStartInfo..::.Password properties
set, the unmanaged CreateProcessWithLogonW function is called, which starts
the process in a new window even if the CreateNoWindow property value is
true or the WindowStyle property value is Hidden."

"Huey" <Hu**@discussions.microsoft.comwrote in message
news:6D**********************************@microsof t.com...
Bumping this one once. I really would like to get a professional opinion
on
how to do this, please.

"Huey" wrote:
I need to hide the new window started from the code below. If I run as
is,
the window is visible. If I comment out the code that sets a different
user,
domain, and password the window is hidden as desired. Does anyone know
if
there is a known issue with hiding a process window when you run it as a
different user? Do you have any suggestions to work around this problem?
Thank you.

Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/C time /T";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.Domain = CurrentAdmin.Domain;
proc.StartInfo.UserName = CurrentAdmin.UserID;
proc.StartInfo.Password = CurrentAdmin.Password;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
StreamReader myOutput = proc.StandardOutput;

proc.WaitForExit();

while (myOutput.EndOfStream == false)
{
string Inline;
Inline = myOutput.ReadLine();
Response = Response + Inline + Environment.NewLine;
}
MessageBox.Show(Response);


Oct 23 '08 #4
No need to, I am glad I could help you.
Sometimes MSDN does it's job well :)
I thought it will say about this in the description of either the method or
structures used in the method.

"Huey" <Hu**@discussions.microsoft.comwrote in message
news:3D**********************************@microsof t.com...
Thanks! I feel sufficiently stupid now. :]

"Andrew" wrote:
>Quote from MSDN for the Process.StartInfo Property:

"If you call the Start(ProcessStartInfo) method with the
ProcessStartInfo..::.UserName and ProcessStartInfo..::.Password
properties
set, the unmanaged CreateProcessWithLogonW function is called, which
starts
the process in a new window even if the CreateNoWindow property value is
true or the WindowStyle property value is Hidden."

"Huey" <Hu**@discussions.microsoft.comwrote in message
news:6D**********************************@microso ft.com...
Bumping this one once. I really would like to get a professional
opinion
on
how to do this, please.

"Huey" wrote:

I need to hide the new window started from the code below. If I run
as
is,
the window is visible. If I comment out the code that sets a
different
user,
domain, and password the window is hidden as desired. Does anyone
know
if
there is a known issue with hiding a process window when you run it as
a
different user? Do you have any suggestions to work around this
problem?
Thank you.

Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/C time /T";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.Domain = CurrentAdmin.Domain;
proc.StartInfo.UserName = CurrentAdmin.UserID;
proc.StartInfo.Password = CurrentAdmin.Password;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
StreamReader myOutput = proc.StandardOutput;

proc.WaitForExit();

while (myOutput.EndOfStream == false)
{
string Inline;
Inline = myOutput.ReadLine();
Response = Response + Inline +
Environment.NewLine;
}
MessageBox.Show(Response);



Oct 23 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Code Monkee | last post by:
How can the toolbar and menubar be hidden in IE? When opening the window via javascript I can specify 'toolbar=no,menubar=no', which works fine. However if the window already exists how can I...
7
by: Danielb | last post by:
I want my application to run most of the time as just an notify icon visible in the system tray, with some dialogs windows that open if the user selects an option from the context menu on the tray...
7
by: Samantha | last post by:
Hello , I am developping a program for Win98 plateform, and I am stucking with a problem, hope you can help me. I have a program running 2 process : - One process running the Xcopy.exe -...
5
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
4
by: drodrig | last post by:
Hi. I am trying to close/kill all processes that show visible windows on Windows XP. So far I've created a script that uses win32gui.EnumWindows to iterate through all windows, check for which...
9
by: SeC | last post by:
Hi. Is there any way to detect if application is being killed by 'End Process' via Task Manager ?
3
by: jan.loucka | last post by:
Hi, Is there any way in .NET how to capture WIN API messages that belong to different application? We have a Windows Form app written in .NET 2.0 and from our application we're running another...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.