473,691 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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...luck ily 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 1502
On Apr 26, 3:13 pm, "RSH" <way_beyond_o.. .@yahoo.comwrot e:
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
6928
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 will function as a windows service and will also present a GUI to the user. I don't want "Interact with desktop"; I want the same exe to run as a normal non-interactive service when started properly by the service control manager, or instead to run...
1
5552
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 runs as a service, I would want it to call ServiceBase.Run (which will then call the execution logic). If it is run at the command-line, I simply want it to run as a normal application.
2
2212
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 following Microsoft Development Environment error message displays: "Object reference not set to an instance of an object." Then when I access the design view of one of my forms, the controls on
4
3153
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 further away, completely leaving the selector box area. Any ideas? VS 2003 and VB.Net This is a simple application at the moment but the form is inherited from a
9
10315
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 PythonMagick source from the ImageMagick site, but I'm on Windows and don't have the ability to compile it. I found reference to a windows installer for PythonMagick on the wxPython wiki, but the links take me to procoders.net, which seems to have abandoned...
7
1277
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 thought about giving it a try in PHP. My problem: I only used PHP inside a webserver untill now, and I have experience with some simple scripts I build for cronjobs in PHP (commandline/cli invocation).
1
6412
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 reason it never gets saved (I open the properties right after, and the box is empty). How does one persist a value in the Start Parameters box for a service? Thanks
3
10130
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 configure it) during a VB.net 2005 deployment project i.e within a custom action? If so some code examples would be appreciated
51
4127
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 Command Prompt or Browser or some other application? Ojas.
0
8600
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9079
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8952
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8796
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5817
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4553
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2234
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.