468,785 Members | 1,508 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,785 developers. It's quick & easy.

Launch windows app with no GUI ?

Hi.

I need to launch a windows application and then send keyboard event to this
process to run certain commands. I've created a COM+ appplication to spawn
and talk to the application which works well however the launched
application always shows the UI where-as I need this to be hidden, even
calling the windowhidden on the process strart info does not work. Does this
somehow need to spawned under a different account process ?

_ProcessInfo = New ProcessStartInfo
_ProcessInfo.WorkingDirectory = node.Item("ProgramDirectory").InnerText
_ProcessInfo.FileName = node.Item("ProgramName").InnerText
_ProcessInfo.Arguments = node.Item("ProgramArguments").InnerText
_ProcessInfo.CreateNoWindow = True
_ProcessInfo.UseShellExecute = False
_ProcessInfo.RedirectStandardOutput = True

Thanks

Paul
Nov 17 '05 #1
7 2399
have you tried to compile it as an exe rather than a winexe

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
Hi.

I need to launch a windows application and then send keyboard event to this process to run certain commands. I've created a COM+ appplication to spawn
and talk to the application which works well however the launched
application always shows the UI where-as I need this to be hidden, even
calling the windowhidden on the process strart info does not work. Does this somehow need to spawned under a different account process ?

_ProcessInfo = New ProcessStartInfo
_ProcessInfo.WorkingDirectory = node.Item("ProgramDirectory").InnerText
_ProcessInfo.FileName = node.Item("ProgramName").InnerText
_ProcessInfo.Arguments = node.Item("ProgramArguments").InnerText
_ProcessInfo.CreateNoWindow = True
_ProcessInfo.UseShellExecute = False
_ProcessInfo.RedirectStandardOutput = True

Thanks

Paul

Nov 17 '05 #2
The application we are spawning is not ours, so we cannot do any recompile.

"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
have you tried to compile it as an exe rather than a winexe

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
Hi.

I need to launch a windows application and then send keyboard event to

this
process to run certain commands. I've created a COM+ appplication to spawn and talk to the application which works well however the launched
application always shows the UI where-as I need this to be hidden, even
calling the windowhidden on the process strart info does not work. Does

this
somehow need to spawned under a different account process ?

_ProcessInfo = New ProcessStartInfo
_ProcessInfo.WorkingDirectory = node.Item("ProgramDirectory").InnerText
_ProcessInfo.FileName = node.Item("ProgramName").InnerText
_ProcessInfo.Arguments = node.Item("ProgramArguments").InnerText
_ProcessInfo.CreateNoWindow = True
_ProcessInfo.UseShellExecute = False
_ProcessInfo.RedirectStandardOutput = True

Thanks

Paul


Nov 17 '05 #3
as you are spawing a windows app, it needs to create its window for it to
work (also to implement its window loop logic). you are stuck with this
behavior. you can remove the create window permission (default with asp.net
and sevices) but then the app probably won't run. you will probably need to
a logon on the server so there is a valid desktop. all in all not a good
solution - you should replaces this app with a server based version as soon
as possible.

note: in ProcessStartInfo, the CreateNoWindow is used for console apps and
shell execute, to determine if a new command window should be created.

-- bruce (sqlwork.com)

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:#i**************@tk2msftngp13.phx.gbl...
The application we are spawning is not ours, so we cannot do any recompile.
"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
have you tried to compile it as an exe rather than a winexe

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
Hi.

I need to launch a windows application and then send keyboard event to

this
process to run certain commands. I've created a COM+ appplication to spawn and talk to the application which works well however the launched
application always shows the UI where-as I need this to be hidden, even calling the windowhidden on the process strart info does not work. Does
this
somehow need to spawned under a different account process ?

_ProcessInfo = New ProcessStartInfo
_ProcessInfo.WorkingDirectory =

node.Item("ProgramDirectory").InnerText _ProcessInfo.FileName = node.Item("ProgramName").InnerText
_ProcessInfo.Arguments = node.Item("ProgramArguments").InnerText
_ProcessInfo.CreateNoWindow = True
_ProcessInfo.UseShellExecute = False
_ProcessInfo.RedirectStandardOutput = True

Thanks

Paul



Nov 17 '05 #4
You might want to try also HWND_MESSAGE parameter in SetParent Win32 API.
I never tried it with separate applications though, but it might work. If
you would test this, please notify about results

HTH
Alex

"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
as you are spawing a windows app, it needs to create its window for it to
work (also to implement its window loop logic). you are stuck with this
behavior. you can remove the create window permission (default with asp.net and sevices) but then the app probably won't run. you will probably need to a logon on the server so there is a valid desktop. all in all not a good
solution - you should replaces this app with a server based version as soon as possible.

note: in ProcessStartInfo, the CreateNoWindow is used for console apps and
shell execute, to determine if a new command window should be created.

-- bruce (sqlwork.com)

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:#i**************@tk2msftngp13.phx.gbl...
The application we are spawning is not ours, so we cannot do any

recompile.

"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
have you tried to compile it as an exe rather than a winexe

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
> Hi.
>
> I need to launch a windows application and then send keyboard event to this
> process to run certain commands. I've created a COM+ appplication to

spawn
> and talk to the application which works well however the launched
> application always shows the UI where-as I need this to be hidden, even > calling the windowhidden on the process strart info does not work. Does this
> somehow need to spawned under a different account process ?
>
> _ProcessInfo = New ProcessStartInfo
> _ProcessInfo.WorkingDirectory = node.Item("ProgramDirectory").InnerText > _ProcessInfo.FileName = node.Item("ProgramName").InnerText
> _ProcessInfo.Arguments = node.Item("ProgramArguments").InnerText
> _ProcessInfo.CreateNoWindow = True
> _ProcessInfo.UseShellExecute = False
> _ProcessInfo.RedirectStandardOutput = True
>
>
>
> Thanks
>
> Paul
>
>



Nov 17 '05 #5
The company who write the software already has a package with uses the same
technology so they somehow have managed to hide the window with the same
executable we are using. Is there any way we can hook into the process
launch and find out what the command parameter was when the app was
launched, for example the users, arguments and window details ?

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:uq*************@TK2MSFTNGP11.phx.gbl...
You might want to try also HWND_MESSAGE parameter in SetParent Win32 API.
I never tried it with separate applications though, but it might work. If
you would test this, please notify about results

HTH
Alex

"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
as you are spawing a windows app, it needs to create its window for it to
work (also to implement its window loop logic). you are stuck with this
behavior. you can remove the create window permission (default with asp.net
and sevices) but then the app probably won't run. you will probably need

to
a logon on the server so there is a valid desktop. all in all not a good
solution - you should replaces this app with a server based version as

soon
as possible.

note: in ProcessStartInfo, the CreateNoWindow is used for console apps and shell execute, to determine if a new command window should be created.

-- bruce (sqlwork.com)

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:#i**************@tk2msftngp13.phx.gbl...
The application we are spawning is not ours, so we cannot do any

recompile.

"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> have you tried to compile it as an exe rather than a winexe
>
> --
> Regards
>
> John Timney (Microsoft ASP.NET MVP)
> ----------------------------------------------
> <shameless_author_plug>
> Professional .NET for Java Developers with C#
> ISBN:1-861007-91-4
> Professional Windows Forms
> ISBN: 1861005547
> Professional JSP 2nd Edition
> ISBN: 1861004958
> Professional JSP
> ISBN: 1861003625
> Beginning JSP Web Development
> ISBN: 1861002092
> </shameless_author_plug>
> ----------------------------------------------
>
> "Paul" <ma********@hotmail.com.nospam> wrote in message
> news:eg**************@TK2MSFTNGP09.phx.gbl...
> > Hi.
> >
> > I need to launch a windows application and then send keyboard event to > this
> > process to run certain commands. I've created a COM+ appplication

to spawn
> > and talk to the application which works well however the launched
> > application always shows the UI where-as I need this to be hidden,

even
> > calling the windowhidden on the process strart info does not work.

Does
> this
> > somehow need to spawned under a different account process ?
> >
> > _ProcessInfo = New ProcessStartInfo
> > _ProcessInfo.WorkingDirectory =

node.Item("ProgramDirectory").InnerText
> > _ProcessInfo.FileName = node.Item("ProgramName").InnerText
> > _ProcessInfo.Arguments = node.Item("ProgramArguments").InnerText
> > _ProcessInfo.CreateNoWindow = True
> > _ProcessInfo.UseShellExecute = False
> > _ProcessInfo.RedirectStandardOutput = True
> >
> >
> >
> > Thanks
> >
> > Paul
> >
> >
>
>



Nov 17 '05 #6
After a day of trying to find some code, I've managed to find the code for
using the CreateProcessWithLogonW to launch the process as a different user,
this works launching the program as a given user but the UI output is still
sent back to the windows application, surely this should effectly run in the
new users desktop process. Once it is spawned I need to be able to use the
SendMessage functions to the app to control the keyboard input, so any ideas
would be great

"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
as you are spawing a windows app, it needs to create its window for it to
work (also to implement its window loop logic). you are stuck with this
behavior. you can remove the create window permission (default with asp.net and sevices) but then the app probably won't run. you will probably need to a logon on the server so there is a valid desktop. all in all not a good
solution - you should replaces this app with a server based version as soon as possible.

note: in ProcessStartInfo, the CreateNoWindow is used for console apps and
shell execute, to determine if a new command window should be created.

-- bruce (sqlwork.com)

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:#i**************@tk2msftngp13.phx.gbl...
The application we are spawning is not ours, so we cannot do any

recompile.

"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
have you tried to compile it as an exe rather than a winexe

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
> Hi.
>
> I need to launch a windows application and then send keyboard event to this
> process to run certain commands. I've created a COM+ appplication to

spawn
> and talk to the application which works well however the launched
> application always shows the UI where-as I need this to be hidden, even > calling the windowhidden on the process strart info does not work. Does this
> somehow need to spawned under a different account process ?
>
> _ProcessInfo = New ProcessStartInfo
> _ProcessInfo.WorkingDirectory = node.Item("ProgramDirectory").InnerText > _ProcessInfo.FileName = node.Item("ProgramName").InnerText
> _ProcessInfo.Arguments = node.Item("ProgramArguments").InnerText
> _ProcessInfo.CreateNoWindow = True
> _ProcessInfo.UseShellExecute = False
> _ProcessInfo.RedirectStandardOutput = True
>
>
>
> Thanks
>
> Paul
>
>



Nov 17 '05 #7
It's not clear to me that this will work. The process will run under that other
account in its own window station with a hidden UI, but your program has to be
in the same window station to have a SendMessage work (let alone get a handle to
a window in another window station). Use the Task Scheduler to fire off
notepad.exe under another user account; it will run invisibly, see if you can
get a window handle to do a SendMessage with.

Phil Wilson [MVP Windows Installer]
----
"Paul" <ma********@hotmail.com.nospam> wrote in message
news:uG**************@TK2MSFTNGP09.phx.gbl...
After a day of trying to find some code, I've managed to find the code for
using the CreateProcessWithLogonW to launch the process as a different user,
this works launching the program as a given user but the UI output is still
sent back to the windows application, surely this should effectly run in the
new users desktop process. Once it is spawned I need to be able to use the
SendMessage functions to the app to control the keyboard input, so any ideas
would be great

"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
as you are spawing a windows app, it needs to create its window for it to
work (also to implement its window loop logic). you are stuck with this
behavior. you can remove the create window permission (default with

asp.net
and sevices) but then the app probably won't run. you will probably need

to
a logon on the server so there is a valid desktop. all in all not a good
solution - you should replaces this app with a server based version as

soon
as possible.

note: in ProcessStartInfo, the CreateNoWindow is used for console apps and
shell execute, to determine if a new command window should be created.

-- bruce (sqlwork.com)

"Paul" <ma********@hotmail.com.nospam> wrote in message
news:#i**************@tk2msftngp13.phx.gbl...
The application we are spawning is not ours, so we cannot do any

recompile.

"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> have you tried to compile it as an exe rather than a winexe
>
> --
> Regards
>
> John Timney (Microsoft ASP.NET MVP)
> ----------------------------------------------
> <shameless_author_plug>
> Professional .NET for Java Developers with C#
> ISBN:1-861007-91-4
> Professional Windows Forms
> ISBN: 1861005547
> Professional JSP 2nd Edition
> ISBN: 1861004958
> Professional JSP
> ISBN: 1861003625
> Beginning JSP Web Development
> ISBN: 1861002092
> </shameless_author_plug>
> ----------------------------------------------
>
> "Paul" <ma********@hotmail.com.nospam> wrote in message
> news:eg**************@TK2MSFTNGP09.phx.gbl...
> > Hi.
> >
> > I need to launch a windows application and then send keyboard event to > this
> > process to run certain commands. I've created a COM+ appplication to
spawn
> > and talk to the application which works well however the launched
> > application always shows the UI where-as I need this to be hidden,

even
> > calling the windowhidden on the process strart info does not work.

Does
> this
> > somehow need to spawned under a different account process ?
> >
> > _ProcessInfo = New ProcessStartInfo
> > _ProcessInfo.WorkingDirectory =

node.Item("ProgramDirectory").InnerText
> > _ProcessInfo.FileName = node.Item("ProgramName").InnerText
> > _ProcessInfo.Arguments = node.Item("ProgramArguments").InnerText
> > _ProcessInfo.CreateNoWindow = True
> > _ProcessInfo.UseShellExecute = False
> > _ProcessInfo.RedirectStandardOutput = True
> >
> >
> >
> > Thanks
> >
> > Paul
> >
> >
>
>



Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Caroline | last post: by
3 posts views Thread by Michel H | last post: by
6 posts views Thread by Francois Bonzon | last post: by
5 posts views Thread by stef mientki | last post: by
2 posts views Thread by =?Utf-8?B?YmVubnlnaQ==?= | last post: by
6 posts views Thread by tempnode | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.