473,405 Members | 2,310 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,405 software developers and data experts.

Running a windows form project from commandline

RSH
Hi,

I have a silly question...

I have a Windows Form project (VB.Net) that was created in Visual Studio
2003. The project runs great.

Now I have to add the ability to run the same application from a
commandline. The obvious issue is going to be with all of the form specific
settings...luckily I wrote the app using classes to seperate the form
specific logic from the business logic.

The issue i have however, is that if I change the Startup object in the
project properties from "Form1" to "SubMain" and then check for commandline
arguments if none exist then I'm instantiating the Form object as follows:

Public Class Form1

Inherits System.Windows.Forms.Form

Public Shared Sub main(ByVal CmdArgs() As String)

if CmdArgs.length 0 then

Dim frm As New Form1

frm.ShowDialog()

else

RunCmdApp()

end if

End Sub

end class

This all seems to work fine from the Commandline, BUT now when there are no
commandline arguments a simple blank form shows (not my form which has all
sorts of controls and such). The class name is Form1 but the filename is
frmMain.vb but that doesnt seem to have anything to do with it.

What am I missing? I want my form back.

Thanks,
Ron
Apr 26 '07 #1
1 1488
On Apr 26, 3:13 pm, "RSH" <way_beyond_o...@yahoo.comwrote:
The issue i have however, is that if I change the Startup object in the
project properties from "Form1" to "SubMain" and then check for commandline
arguments if none exist then I'm instantiating the Form object as follows:
You code seems to instantiate the form if there *is* command line
arguments
>
Public Class Form1

Inherits System.Windows.Forms.Form

Public Shared Sub main(ByVal CmdArgs() As String)

if CmdArgs.length 0 then

Dim frm As New Form1

frm.ShowDialog()

else

RunCmdApp()

end if

End Sub

end class

This all seems to work fine from the Commandline, BUT now when there are no
commandline arguments a simple blank form shows (not my form which has all
Again, your code only instantiates the form if CmdArgs.Length 0

It should show the form you designed. Could you copy the exact code
that you use? Or provide a short but complete example that
demonstrates the problem? You might also try this instead:

If CmdArgs.Length 0 Then
RunCmdApp()
Else
Application.Run(New Form1)
End If

Is the code you provided all there is to the Form1 class?

Chris
Apr 27 '07 #2

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

Similar topics

7
by: Ross Presser | last post by:
OK, I've been researching this problem and can't find a definitive answer yet. The situation is one that seems to have come up a few times to different folks. I am writing an application that...
1
by: Peter Rilling | last post by:
I have an EXE that I would like to be able to run from either the command-line or as a windows service. Is there a way that I can tell which context the program is running in? Basically, if it...
2
by: Jeff | last post by:
I'm getting an Object Reference error before I even run my app, and I'm not sure where to look to find the cause. I'd appreciate your help. When I open my Windows Application project, the...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
9
by: Adam Endicott | last post by:
Does anyone know anything about PythonMagick? I've got a project that could use ImageMagick, so I went looking around for PythonMagick, and I'm a bit lost. I was able to download the...
7
by: Erwin Moller | last post by:
Hi Group, I am starting on some project and need to program all kinds of windows with buttons/textfields/etc. My natural reaction was to build this in Java, but since I like PHP so much I...
1
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... After I installed my .net windows service, I tried to control some of the behavior with the Start Parameters: in the services control parameter. I can put a value in the box but for some...
3
by: Steve | last post by:
Hi All I have a Windows forms POS program and have windows xp printer drivers for the Posiflex printers the customers use Is it possible to automatically install a windows printer driver (and...
51
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.