Running an exe automatically - form invisible


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I have a small app(not strataframe, plain vanilla c#) which does some updating and consists of just one form with a few buttons. This exe is also set up to run automatically, which is controlled by means of a parameter passed in e.g. MyExe "1". If I just run a MyExe without the parameter, I want the form to appear so I can click a few buttons. if I run MyExe with the parameter, i just want the form to run stuff on one of the buttons. I have this all working. My problem is that , when I run in unattended mode, the form itself does not display on the screen. The form runs ok but I cant see what its doing. I know when the form is up and running there is no benefit to be able to 'see' the form (as it will be running in unattended mode)  but at this stage I would like to see the form and its associated messages. If I was doing this in VFP, I would have a MyForm.Show.

Is there something similar I need to do , to get visibility of the form ?

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Gerard,

Can you post the code you are using to show the form? or better yet, small sample application with desired functionality.

Edhy Rijo

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Perhaps a slightly different approach would be to utilize the NotifyIcon on the main form. Just drag one on the form from the Common Controls section. Use your startup parameter to start the form minimized or maximized. On the form load you could check to see which state it is in, then run the appropriate methods. Lots of options available with this little object.



Hope that helps!

Bill
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Gerard,



I've created a couple of sample apps to demonstrate a couple of ways to do this.



The first way, via the UnattendedModeSample, shows how to have your exe be opened either with a normal UI or to just automatically run a process. The process opens a status form and updates it no matter how it is called.



The second method is more robust, decoupling the process entirely from any UI. The other three projects demonstrate this. The SampleProcess project has a class that runs a process. When the process runs, it raises an event ProcessStepCompleted that consumers can handle to display messages from the process. The ProcessWinformUI will display the process messages in a textbox on the form, while the ProcessConsoleUI displays the progress to the command window.



The second method allows for completely unattended running, use in batch files etc. because the process runs completely with without user interface.



Attachments
UnattendedModeSample.zip (110 views, 40.00 KB)
Russell Scott Brown
Russell Scott Brown
StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)
Group: Forum Members
Posts: 124, Visits: 597
Thanks for the examples!

Russ Brown (Using C#2010/SQL Server 2008)
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
My pleasure!
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Greg, thanks for samples.

I have been off on a tangent doing other things but hopefully will get to look at these in the next while.

Regards,

Gerard

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search