473,657 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing Parameters to Console Application

How would I pass parameters to a console application? I would like to do
something like this:

consoleapp.exe /o \\fileshare\ori gindirectory /d
\\fileshare\des tinationdirecto ry

I'm not sure how to start the console app to read from the command line.
Any assistance would be appreciated!

Michael Hetrick
Nov 13 '05 #1
1 18276
Thanks - it was the part about the args[] in Main!

"Jonathan Schafer" <jschafer@*NOSP AM*brierley.a.b .c.com> wrote in message
news:43******** *************** *********@4ax.c om...
On Tue, 15 Jul 2003 20:59:43 -0400, "Michael Hetrick"
<m1******@gc.co m> wrote:
How would I pass parameters to a console application? I would like to do
something like this:

consoleapp.e xe /o \\fileshare\ori gindirectory /d
\\fileshare\de stinationdirect ory

I'm not sure how to start the console app to read from the command line.
Any assistance would be appreciated!

Michael Hetrick


I'm a little unsure what you are asking...

If you are asking how to start a console program from another .NET
program (with or without parameters), use the Process class. You can
set up the name of the exe to run, parameters, etc.

If you are wondering how to handle parameters passed to a .NET console
program, they are already parsed for you via the args[] in the main
function. Each parameter is in the array and I believe the arguments
are split on white space. So, given your above command line, args[0]
would contain /o, args[1] would contain \\fileshare\ori gindirectory,
etc.

There may be an issue however, if your directory path contains one or
more spaces in it. Then it may split that argument into separate
arguments where the spaces exist and you'd have to piece it back
together.

If neither of these answers your question, then either someone who
understood your question better will answer or you can post a more
specific question.

Jonathan Schafer

Nov 13 '05 #2

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

Similar topics

5
36397
by: Andy | last post by:
Hi Could someone clarify for me the method parameter passing concept? As I understand it, if you pass a variable without the "ref" syntax then it gets passed as a copy. If you pass a variable with the "ref" syntax then it gets passed as a reference to the object and any changes to
3
442
by: AndyDunning | last post by:
Hello, I'm interested in establishing the best way to pass information between a vb script and a .net application. We have a VbScript that runs on a users pc every time a phone call is routed to that user, this script is provided by out telecom provide. The Script contains call details e.g. incoming number. My aim is to pass data from this vb script to my .net app.
7
4742
by: Ken Allen | last post by:
I have a .net client/server application using remoting, and I cannot get the custom exception class to pass from the server to the client. The custom exception is derived from ApplicationException and is defined in an assembly common to the client and server components. The custom class merely defines three (3) constructors -- the null constructor; one with a string parameter; and one with a string and innner exception parameter -- that...
1
3122
by: Darsin | last post by:
Hi all, I am a new programmer to C# and i am having a following problem. I want to make a single method which takes a variable length array and display it contents. i have defined the method as: public void DisplayVals(params object objArray) { foreach (object o in objArray) Console.WriteLine(o.ToString()); }
13
2786
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
1
4099
by: kplkumar | last post by:
I am trying to get the method and the parameters passed to that method from the stackTrace. My code is, private void GetExecutingMethodInfo() { StackTrace trace = new StackTrace(false); for (int index = 0; index < trace.FrameCount; ++index)
3
10107
by: Alex | last post by:
Hello, I'm wroting a console utility in VB 2005, and I need the ability to pass parameters to the application when the program runs. For example, if my program is called testing.exe, I need to be able to run this: c:\testing.exe c:\test ....and have 'c:\test' passed to the program as a variable. Most of my VB books focus on web forms or windows forms, but not much details on console
1
7579
by: =?Utf-8?B?U3Jpaw==?= | last post by:
Hi, I have a console application which needs to be run at periodic intervals. So, I want to add it in Windows Task Scheduler but at the same time, I need to pass parameters to the Application (Task). Please let me know how can we pass parameters for those applications(that run from Task Scheduler). Thanks in Advance...
1
2197
by: ramjannu | last post by:
How would I pass parameters to a console application? I'm not sure how to start the console app to read from the command line.
0
8315
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
8734
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...
1
8508
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
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
7341
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...
1
6172
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.