Hi, I've seen sample vb project. It's a console application.
There's a code there like Dim q() As String = Environment.GetCommandLineArgs()

First I try to check it by using message box to print it out:
the index-0 of q contain a path project vshost --> q(0)="D:\TestService\sample1.vshost.exe"
and the index-1 of q contain a xml file --> q(1)="Setting.xml"

The thing I really confuse is, from where the Environment.GetCommandLineArgs() get that both q(0) and q(1)?

I've tried to search both and can't found any code which is contain the path to load it, then I try to delete the all complied files in debug folder and then rebuild it, the strange thing happen, I mean the "Setting xml" file automatically created and appear again although it doesn't has the same contain as it has first which is remain <configuration> only. The original contain of the Setting.xml is some IP and database name.

Is there any setting which can make the vb.net create the Setting.xml? Because I don't find either the code for creating this Setting.xml or the tool bar for set it. please help.

Member Avatar for Huntondoom

Environment.getcommandlineargs()
is a command that gets the arguments that were used to startup your application
usually the first line is the path your .exe file.
second is a file that is used for you Settings in your form
this is just a file that is automatically generated by your compiler.

if you want to use GetCommandLineargs()
then I suggest you do this:

open notepad. then type in this Batch code:

@echo off
Start D:\TestService\sample1.vshost.exe Setting.xml HelloWolrd! Are You seeing this?

save it as <something>.bat
and run it
should work

Thanks, I've tried to run it, but the command promt just open and close so fast before I can see it clearly. Finally I know how to test it then how to make the cmd close just after event click done like c++ getch() subroutine provides.

Thanks, I've tried to run it, but the command promt just open and close so fast before I can see it clearly. Finally I know how to test it then how to make the cmd close just after event click done like c++ getch() subroutine provides.

No, this won't print out the line argument on command prompt, he invoke arguments of D:\TestService\sample1.vshost.exe by HelloWolrd! and Are You seeing this?.
In order to see the command line arguments, you must print out this inside the D:\TestService\sample1.vshost.exe. These (HelloWolrd! and Are You seeing this?) arguments are passed.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.