473,385 Members | 1,942 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,385 software developers and data experts.

Get command arguments in Windows Service

I created a Windows Service in C# that requires to get
passed command arguments like a Console App. I noticed
that there is an option "Start parameters" text box in
the property of a Windows Service in MMC. Is there any
way to get arguments using this option? If possible, what
framework method should I use to get an arguement?
Thanks in advance.

Eric
Jul 19 '05 #1
5 7127
Hi Eric,

You may try the Environment.GetCommandLineArgs Method.
Here is a helpful link.
Did I answer your question?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Eric Chong" <ec********@hotmail.com>
Sender: "Eric Chong" <ec********@hotmail.com>
Subject: Get command arguments in Windows Service
Date: Fri, 5 Sep 2003 11:14:28 -0700
Lines: 9
Message-ID: <22****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcNz2Yt3Dhmj8jm/RlO1ml5VJWd4bw==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:107449
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.general

I created a Windows Service in C# that requires to get
passed command arguments like a Console App. I noticed
that there is an option "Start parameters" text box in
the property of a Windows Service in MMC. Is there any
way to get arguments using this option? If possible, what
framework method should I use to get an arguement?
Thanks in advance.

Eric


Jul 21 '05 #2
Thank you for your reply. However, your solution doesn't
work. I've already tried this. I think a Start parameter
of Windows Service doesn't pass any argument to
GetCommandLineArgs method.

Eric
-----Original Message-----
Hi Eric,

You may try the Environment.GetCommandLineArgs Method.
Here is a helpful link.
Did I answer your question?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.--------------------
Content-Class: urn:content-classes:message
From: "Eric Chong" <ec********@hotmail.com>
Sender: "Eric Chong" <ec********@hotmail.com>
Subject: Get command arguments in Windows Service
Date: Fri, 5 Sep 2003 11:14:28 -0700
Lines: 9
Message-ID: <22****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcNz2Yt3Dhmj8jm/RlO1ml5VJWd4bw==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:107449NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.general

I created a Windows Service in C# that requires to get
passed command arguments like a Console App. I noticed
that there is an option "Start parameters" text box in
the property of a Windows Service in MMC. Is there any
way to get arguments using this option? If possible, whatframework method should I use to get an arguement?
Thanks in advance.

Eric


.

Jul 21 '05 #3
Hi Eric,

Sorry for misunderstanding your quesiton.
Did you mean that you want to get the parameters in "Start parameters" text
box in
the property of a Windows Service in MMC in your services program?

If so, I think the args argument in the function
protected override void OnStart(string[] args)
is what you want.

Here is simple sample. You may have a check.
Windows Services: New Base Classes in .NET Make Writing a Windows Service
Easy
http://msdn.microsoft.com/msdnmag/is...v/default.aspx
Did I misunderstand your question?
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Eric Chong" <ec********@hotmail.com>
Sender: "Eric Chong" <ec********@hotmail.com>
References: <22****************************@phx.gbl> <Gx**************@cpmsftngxa06.phx.gbl>Subject: RE: Get command arguments in Windows Service
Date: Mon, 8 Sep 2003 09:16:28 -0700
Lines: 56
Message-ID: <41****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN2JI7qoR2H+AzdR9ucVL9fs0/JAw==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:107680
NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
X-Tomcat-NG: microsoft.public.dotnet.general

Thank you for your reply. However, your solution doesn't
work. I've already tried this. I think a Start parameter
of Windows Service doesn't pass any argument to
GetCommandLineArgs method.

Eric
-----Original Message-----
Hi Eric,

You may try the Environment.GetCommandLineArgs Method.
Here is a helpful link.
Did I answer your question?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and

confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Eric Chong" <ec********@hotmail.com>
Sender: "Eric Chong" <ec********@hotmail.com>
Subject: Get command arguments in Windows Service
Date: Fri, 5 Sep 2003 11:14:28 -0700
Lines: 9
Message-ID: <22****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcNz2Yt3Dhmj8jm/RlO1ml5VJWd4bw==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gblmicrosoft.public.dotnet.general:107449NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.general

I created a Windows Service in C# that requires to get
passed command arguments like a Console App. I noticed
that there is an option "Start parameters" text box in
the property of a Windows Service in MMC. Is there any
way to get arguments using this option? If possible,whatframework method should I use to get an arguement?
Thanks in advance.

Eric


.


Jul 21 '05 #4
Thank you very much!!! It works.

Eric
-----Original Message-----
Hi Eric,

Sorry for misunderstanding your quesiton.
Did you mean that you want to get the parameters in "Start parameters" textbox in
the property of a Windows Service in MMC in your services program?
If so, I think the args argument in the function
protected override void OnStart(string[] args)
is what you want.

Here is simple sample. You may have a check.
Windows Services: New Base Classes in .NET Make Writing a Windows ServiceEasy
http://msdn.microsoft.com/msdnmag/is...12/NETServ/def ault.aspx

Did I misunderstand your question?
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.--------------------
Content-Class: urn:content-classes:message
From: "Eric Chong" <ec********@hotmail.com>
Sender: "Eric Chong" <ec********@hotmail.com>
References: <22****************************@phx.gbl>

<Gx**************@cpmsftngxa06.phx.gbl>
Subject: RE: Get command arguments in Windows Service
Date: Mon, 8 Sep 2003 09:16:28 -0700
Lines: 56
Message-ID: <41****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN2JI7qoR2H+AzdR9ucVL9fs0/JAw==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:107680NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
X-Tomcat-NG: microsoft.public.dotnet.general

Thank you for your reply. However, your solution doesn't
work. I've already tried this. I think a Start parameter
of Windows Service doesn't pass any argument to
GetCommandLineArgs method.

Eric
-----Original Message-----
Hi Eric,

You may try the Environment.GetCommandLineArgs Method.
Here is a helpful link.
Did I answer your question?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and

confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Eric Chong" <ec********@hotmail.com>
Sender: "Eric Chong" <ec********@hotmail.com>
Subject: Get command arguments in Windows Service
Date: Fri, 5 Sep 2003 11:14:28 -0700
Lines: 9
Message-ID: <22****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300Thread-Index: AcNz2Yt3Dhmj8jm/RlO1ml5VJWd4bw==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl

microsoft.public.dotnet.general:107449
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.general

I created a Windows Service in C# that requires to get
passed command arguments like a Console App. I noticed
that there is an option "Start parameters" text box in
the property of a Windows Service in MMC. Is there any
way to get arguments using this option? If possible,

what
framework method should I use to get an arguement?
Thanks in advance.

Eric
.


.

Jul 21 '05 #5
Hi Eric,

Cool!
I am glad that it works for you.
Cheers!
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Eric Chong" <ec********@hotmail.com>
Sender: "Eric Chong" <ec********@hotmail.com>
References: <22****************************@phx.gbl> <Gx**************@cpmsftngxa06.phx.gbl>
<41****************************@phx.gbl>
<og**************@cpmsftngxa06.phx.gbl>Subject: RE: Get command arguments in Windows Service
Date: Tue, 9 Sep 2003 09:37:41 -0700
Lines: 120
Message-ID: <01****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN28K/Xk95AzBuTTU+pEbhRPyiRqQ==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:107813
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.general

Thank you very much!!! It works.

Eric
-----Original Message-----
Hi Eric,

Sorry for misunderstanding your quesiton.
Did you mean that you want to get the parameters

in "Start parameters" text
box in
the property of a Windows Service in MMC in your services

program?

If so, I think the args argument in the function
protected override void OnStart(string[] args)
is what you want.

Here is simple sample. You may have a check.
Windows Services: New Base Classes in .NET Make Writing a

Windows Service
Easy
http://msdn.microsoft.com/msdnmag/is...12/NETServ/def

ault.aspx


Did I misunderstand your question?
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and

confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Eric Chong" <ec********@hotmail.com>
Sender: "Eric Chong" <ec********@hotmail.com>
References: <22****************************@phx.gbl>

<Gx**************@cpmsftngxa06.phx.gbl>
Subject: RE: Get command arguments in Windows Service
Date: Mon, 8 Sep 2003 09:16:28 -0700
Lines: 56
Message-ID: <41****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcN2JI7qoR2H+AzdR9ucVL9fs0/JAw==
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gblmicrosoft.public.dotnet.general:107680NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
X-Tomcat-NG: microsoft.public.dotnet.general

Thank you for your reply. However, your solution doesn't
work. I've already tried this. I think a Start parameter
of Windows Service doesn't pass any argument to
GetCommandLineArgs method.

Eric

-----Original Message-----
Hi Eric,

You may try the Environment.GetCommandLineArgs Method.
Here is a helpful link.
Did I answer your question?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and
confers no rights.
--------------------
>Content-Class: urn:content-classes:message
>From: "Eric Chong" <ec********@hotmail.com>
>Sender: "Eric Chong" <ec********@hotmail.com>
>Subject: Get command arguments in Windows Service
>Date: Fri, 5 Sep 2003 11:14:28 -0700
>Lines: 9
>Message-ID: <22****************************@phx.gbl>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>X-MimeOLE: Produced By Microsoft MimeOLEV5.50.4910.0300>Thread-Index: AcNz2Yt3Dhmj8jm/RlO1ml5VJWd4bw==
>Newsgroups: microsoft.public.dotnet.general
>Path: cpmsftngxa06.phx.gbl
>Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.general:107449
>NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
>X-Tomcat-NG: microsoft.public.dotnet.general
>
>I created a Windows Service in C# that requires to get
>passed command arguments like a Console App. I noticed
>that there is an option "Start parameters" text box in
>the property of a Windows Service in MMC. Is there any
>way to get arguments using this option? If possible,
what
>framework method should I use to get an arguement?
>Thanks in advance.
>
>Eric
>

.


.


Jul 21 '05 #6

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

Similar topics

1
by: tuckkhai | last post by:
Hi, I am a newbie in this area. I would like to know whether is it possible to execute shell command in windows service. I had install a program in the server which i would like it to be executed...
4
by: Primo | last post by:
Hi, This problem has been frustrating me for days and I hope you experts can help me out. I am trying to run a command, which I would normally run from the command line, from within my C#...
3
by: BROQ | last post by:
Hi, I am using a windows service to extract every hour a log from our mailserver in order to parse the logfile. To do this I used the folowing code: Shell("""C:\pscp"" -pw *******...
5
by: Eric Chong | last post by:
I created a Windows Service in C# that requires to get passed command arguments like a Console App. I noticed that there is an option "Start parameters" text box in the property of a Windows...
4
by: Fei | last post by:
Hi, I got a strange problem. I use Macrovision installshield x express edition to build a simple MSI file. I can install this mis silently, i.e using /qn. It has no problem to run either in the...
1
by: dmuralikumar | last post by:
Hi All, I am finding it difficult to send some parameters to the exe corresponding to a Windows Service that has been installed.Its the same case with the exe i.e., I dont where i have to make the...
2
by: Chris Mullins | last post by:
For some reason the question, "Can I make an EXE that is both a Windows Service and a Console Application?" has come up quite a bit for me over the last few weeks. I've been doing this for...
2
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
Hi, I have 2 applications running, one Windows application project and the other windows services project. I want to call my Windows application in my windows services. I want to run them as...
1
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
Hi, I have 2 applications running, one Windows application project and the other windows services project. I want to call my Windows application in my windows services. I want to run them as...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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
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...

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.