|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
howto make a console app start with window minimizedHi,
I have a console app which is simply called from another app which passes a filename to it for processing. It does not display anything or require any input. All errors are sent to the eventlog. As this app is really just a wrapper for a class library I don't need it "popping" up on the console and would like it to be either invisible or for the console window to run minimized in the taskbar. Any suggestions on how I might achieve this? Thanks, Paul > I have a console app which is simply called from another app which passes a I run an exe file without a window as follows:> filename to it for processing. It does not display anything or require any > input. All errors are sent to the eventlog. > As this app is really just a wrapper for a class library I don't need it > "popping" up on the console and would like it to be either invisible or for > the console window to run minimized in the taskbar. Dim p As New Process With p.StartInfo .FileName = "yourprogname.exe" .Arguments = "yourfilename" .UseShellExecute = False .RedirectStandardError = True .RedirectStandardInput = True .RedirectStandardOutput = True .WindowStyle = ProcessWindowStyle.Hidden .CreateNoWindow = True End With Try p.Start() 's = p.StandardOutput.ReadToEnd() 'p.WaitForExit() Catch ex As Exception 's = ex.ToString End Try Toward the end, a few lines are commented out. These lines read stdout of the launched program and cause the launching program to wait for completion. If you want to launch and forget, then leave them out. Thanks AMercer,
I'm not sure where to put this code. I stuck it in the Main() and it still launches the console window before executing the process object. I should mention that the process that calls my routine is a 3rd party product that simply runs an executable specified property) when a particular event occurs. I suspect that I could use your code in the calling routine but unfortuanately I don't have that option. Am I trying to use the code incorrectly? Thanks, Paul Show quoteHide quote "AMercer" <AMer***@discussions.microsoft.com> wrote in message news:FC834503-AF78-48DF-AB7E-EFFE71FBF36A@microsoft.com... >> I have a console app which is simply called from another app which passes >> a >> filename to it for processing. It does not display anything or require >> any >> input. All errors are sent to the eventlog. >> As this app is really just a wrapper for a class library I don't need it >> "popping" up on the console and would like it to be either invisible or >> for >> the console window to run minimized in the taskbar. > > I run an exe file without a window as follows: > > Dim p As New Process > With p.StartInfo > .FileName = "yourprogname.exe" > .Arguments = "yourfilename" > .UseShellExecute = False > .RedirectStandardError = True > .RedirectStandardInput = True > .RedirectStandardOutput = True > .WindowStyle = ProcessWindowStyle.Hidden > .CreateNoWindow = True > End With > Try > p.Start() > 's = p.StandardOutput.ReadToEnd() > 'p.WaitForExit() > Catch ex As Exception > 's = ex.ToString > End Try > > Toward the end, a few lines are commented out. These lines read stdout of > the launched program and cause the launching program to wait for > completion. > If you want to launch and forget, then leave them out. > I suspect I didn't understand your question, and I'm not sure I do now.
Assume exe P1 launches exe P2. The code I specified resides in P1 and is used to launch a windowless P2. If this doesn't help you (ie you are coding P2 and P1 is someone else's), then you are at the mercy of how P1 is coded. There may be a way for P2 to determine how it was launched and influence its operation, but I have no experience in that. Maybe you could change P2 into windows program, and you could control your visibility destiny directly. You might consider that - it is legitimate for a windows exe (vice a console exe) to run to completion without ever creating a window. Hi AMercer,
Thanks for that. Yes P2 = my code and P1 = someone else's. I will try the "windowless" windows forms approach and see how I get on. Thanks again, Paul Show quoteHide quote "AMercer" <AMer***@discussions.microsoft.com> wrote in message news:85A471CF-D349-4F7B-B71A-9C57B815CBB9@microsoft.com... >I suspect I didn't understand your question, and I'm not sure I do now. > Assume exe P1 launches exe P2. The code I specified resides in P1 and is > used to launch a windowless P2. > > If this doesn't help you (ie you are coding P2 and P1 is someone else's), > then you are at the mercy of how P1 is coded. There may be a way for P2 > to > determine how it was launched and influence its operation, but I have no > experience in that. Maybe you could change P2 into windows program, and > you > could control your visibility destiny directly. You might consider that - > it > is legitimate for a windows exe (vice a console exe) to run to completion > without ever creating a window. > Hi AMercer,
Thanks for the help. The last bit about the window app without a form sent me in the right direction. I simply changed the project output to Windows App. and no more console window. Great. Paul Show quoteHide quote "AMercer" <AMer***@discussions.microsoft.com> wrote in message news:85A471CF-D349-4F7B-B71A-9C57B815CBB9@microsoft.com... >I suspect I didn't understand your question, and I'm not sure I do now. > Assume exe P1 launches exe P2. The code I specified resides in P1 and is > used to launch a windowless P2. > > If this doesn't help you (ie you are coding P2 and P1 is someone else's), > then you are at the mercy of how P1 is coded. There may be a way for P2 > to > determine how it was launched and influence its operation, but I have no > experience in that. Maybe you could change P2 into windows program, and > you > could control your visibility destiny directly. You might consider that - > it > is legitimate for a windows exe (vice a console exe) to run to completion > without ever creating a window. >
VS2003 to VS2005 Conversion
Email attachments? Put standard output into file Spell checker How can you add a custom user control to a datagridview? modal dialog box Running app on Shared Drive Export from VB.NET 2003 to an Excel spreadsheet DataGridView... defaults to DataGridViewTextBoxColumn Datagrid Plus Sign Event |
|||||||||||||||||||||||