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

ServiceController.ExecuteCommand() throws Exception,...

Hi,

i have a application that can open an user defined service
at will and can send a User Definded Control Code to it.
I know that the OS restricts/reserves the usage of all
Codes below 127 to the OS itself, so this might be the
reason why executin the Code below 128 either raises
and Invalid Argument Exception (underlying OS Exception)
or an Acess Denied Exception (also underlying OS Exceptions
detail message). But can i bypass this restriction with some
e.g. Token Modification/Environment Change/Context Switch to
whatever or a windows api call in that way, that i can call all codes
from 0 to 255? I want to use a single function call like the
ExecuteCommand(...),...

TIA,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
Jun 27 '08 #1
6 4253
On May 28, 8:25*am, "Kerem Gümrükcü" <kareem...@hotmail.comwrote:
Hi,

i have a application that can open an user defined service
at will and can send a User Definded Control Code to it.
I know that the OS restricts/reserves the usage of all
Codes below 127 to the OS itself, so this might be the
reason why executin the Code below 128 either raises
and Invalid Argument Exception (underlying OS Exception)
or an Acess Denied Exception (also underlying OS Exceptions
detail message). But can i bypass this restriction with some
e.g. Token Modification/Environment Change/Context Switch to
whatever or a windows api call in that way, that i can call all codes
from 0 to 255? I want to use a single function call like the
ExecuteCommand(...),...
What error are you getting?
are you sure you have permission?
I do not think that your problem is with the command, but in any case
use a bigger number, like in the 1000
Jun 27 '08 #2
Hi Ignacio,

i have suffcient rights and my application runs
with all priviliges enabled and under administrative
power and also under system account if i like to.
The point is that you cant send control codes
under 128 directly to a service and must use
your own control codes upper 127 but max 255
if you want to send your own codes to a service,
mainly your own service. So is the operating systems
restriction! But i was asking for a way to bypass this, if
it is possible.But i found out, that it is not,...!

Thanks for your answer,...

Regards

K.

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Ignacio Machin ( .NET/ C# MVP )" <ig************@gmail.comschrieb im
Newsbeitrag
news:76**********************************@q24g2000 prf.googlegroups.com...
On May 28, 8:25 am, "Kerem Gümrükcü" <kareem...@hotmail.comwrote:
Hi,

i have a application that can open an user defined service
at will and can send a User Definded Control Code to it.
I know that the OS restricts/reserves the usage of all
Codes below 127 to the OS itself, so this might be the
reason why executin the Code below 128 either raises
and Invalid Argument Exception (underlying OS Exception)
or an Acess Denied Exception (also underlying OS Exceptions
detail message). But can i bypass this restriction with some
e.g. Token Modification/Environment Change/Context Switch to
whatever or a windows api call in that way, that i can call all codes
from 0 to 255? I want to use a single function call like the
ExecuteCommand(...),...
What error are you getting?
are you sure you have permission?
I do not think that your problem is with the command, but in any case
use a bigger number, like in the 1000
Jun 27 '08 #3
Kerem Gümrükcü wrote:
Hi Ignacio,

i have suffcient rights and my application runs
with all priviliges enabled and under administrative
power and also under system account if i like to.
The point is that you cant send control codes
under 128 directly to a service and must use
your own control codes upper 127 but max 255
if you want to send your own codes to a service,
mainly your own service. So is the operating systems
restriction! But i was asking for a way to bypass this, if
it is possible.But i found out, that it is not,...!
I am not sure where you get the idea that the max argument is 255.
ExecuteCommand() in ServiceController takes an int argument as does
OnCustomCommand() in ServiceBase. You should be able to send any argument from
-2147483648 to 2147483647.

HTH,
-rick-
Jun 27 '08 #4
Hi Ricks,
>I am not sure where you get the idea that the max argument is 255.
ExecuteCommand() in ServiceController takes an int argument as does
OnCustomCommand() in ServiceBase. You should be able to send any argument
from -2147483648 to 2147483647.
http://msdn.microsoft.com/en-us/libr...08(VS.85).aspx

See section "Control Code",...

Obviously the .NET Function calls this or the Ex Function, i didnt check it,
but the case is that it can raise a Win32Exception and it does in my case.
So the Parameter for ExecuteCommand does not rely on its DataType, but
rather on the value. But i see now, that the OS is restricting and reserving
Control Codes below 128 to its private usage and does not accept codes
from an externall application sending them,...

I was looking for some way of doing this to support the complete range of
control codes in my application, but this is AFAIK not possible and i cant
see any bypassing methdo,..and there is no need for anymore,...

Thanks for your reply,...
Regards

Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Rick Lones" <Wr******@YcharterZ.netschrieb im Newsbeitrag
news:wG****************@newsfe05.lga...
Kerem Gümrükcü wrote:
>Hi Ignacio,

i have suffcient rights and my application runs
with all priviliges enabled and under administrative
power and also under system account if i like to.
The point is that you cant send control codes
under 128 directly to a service and must use
your own control codes upper 127 but max 255
if you want to send your own codes to a service,
mainly your own service. So is the operating systems
restriction! But i was asking for a way to bypass this, if
it is possible.But i found out, that it is not,...!
I am not sure where you get the idea that the max argument is 255.
ExecuteCommand() in ServiceController takes an int argument as does
OnCustomCommand() in ServiceBase. You should be able to send any argument
from -2147483648 to 2147483647.

HTH,
-rick-

Jun 27 '08 #5
Kerem Gümrükcü wrote:
Hi Rick,

you can bypass this by extending the servicecontroller
and implementing some IPC mechanism to share large
amounts of real data structures between any application
and even any operating system as far your ipc technique
allows this. I solved it with a three way implementation:
sockets, named pipes and shared memory in a single
service. The service can handle sockt connections from
any IPv4 and IPv6 Connections, uses a OutputDebugString
like memory mapped mechanism and also can handle
named pipe connections. This way i can send any data
to the service as a endpoint. You also can use any
communication method like WCF or newer things, it
depends on you,...
Yes, I was thinking that if more data needed to be transferred (not an excessive
amount, just parameters and switch settings and like that) then the custom
command could be used to kick off a message dialog via remoting or some such
mechanism. Looked into it a bit this afternoon - kind of attractive simply
because I haven't done remoting before. As you say, there are a lot of ways . . .

Regards,
-rick-
Jun 27 '08 #6
Hi Rick,

i liked the Memmory Mappped approach if
it will run on the local machine. There will be
no Firewall to configure and it is really fast,
as long it is local and a point to point
communication and you wont serve to more
clients but just one,...

That maybe will give you an insight view:
http://www.codeproject.com/KB/threads/csthreadmsg.aspx

If you want to serve .NET only clients stay at .NET
only technologies. If you want to serve any type
of client, then stay at a mechanism that will be at
Operating System Level and can be "created"
with Windows API Exports, due to the fact that
neraly any modern language can use the windows
API today,...

Regards

Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Rick Lones" <Wr******@YcharterZ.netschrieb im Newsbeitrag
news:hB***************@newsfe02.lga...
Kerem Gümrükcü wrote:
>Hi Rick,

you can bypass this by extending the servicecontroller
and implementing some IPC mechanism to share large
amounts of real data structures between any application
and even any operating system as far your ipc technique
allows this. I solved it with a three way implementation:
sockets, named pipes and shared memory in a single
service. The service can handle sockt connections from
any IPv4 and IPv6 Connections, uses a OutputDebugString
like memory mapped mechanism and also can handle
named pipe connections. This way i can send any data
to the service as a endpoint. You also can use any
communication method like WCF or newer things, it
depends on you,...
Yes, I was thinking that if more data needed to be transferred (not an
excessive amount, just parameters and switch settings and like that) then
the custom command could be used to kick off a message dialog via remoting
or some such mechanism. Looked into it a bit this afternoon - kind of
attractive simply because I haven't done remoting before. As you say,
there are a lot of ways . . .

Regards,
-rick-

Jun 27 '08 #7

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

Similar topics

1
by: ucasesoftware | last post by:
Dim myController As ServiceController myController = New ServiceController("myWrondName") i try : if myController is nothing then messagebox.show("This service doesn't exist" end if but...
10
by: Bill Burris | last post by:
How do I set the ServiceType to InteractiveProcess, since this property is read only? Is there a way to set this with code in my Installer class, or a standalone process? I normally set this...
1
by: Tom J | last post by:
What do I have to do to get System.ServiceProcess.ServiceController.ExecuteCommand(int) to work? I have written a service that overrides OnCustomCommand to handle commands sent to it. If I...
1
by: Maksim Chepel | last post by:
I'm trying to use ExecuteCommand method of System.ServiceProcess.ServiceController in my C# service controller app to make a custom call to my service. I'm getting this exception and my service...
5
by: Primera | last post by:
I use the following method to stop the WMI service: string serviceName = "Windows Management Instrumentation" public static void stopService(string serviceName) { ServiceController services =...
3
by: Bram Hoefnagel | last post by:
Hi, On the 1.1 framework I couldn't find a solution to get a list of services from an other PC. Only a list of services on My local PC. (witch is strange i guess, as you look to the MSDN doc.) ...
1
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I issue a ExecuteCommand, is there a way to get a response from the service when the command has been executed? What i want to do is to change an icon on the servicecontroller app,...
7
by: =?Utf-8?B?YXVsZGg=?= | last post by:
hello, i'm try to research the way to open a remote machine's to collect the services and processes. i have the local data collection running but i can not figure out what MSDN or the C# help file...
0
by: whm | last post by:
The page http://msdn2.microsoft.com/en-us/708fb7c4(VS.80).aspx has this code: ServiceController^ sc = gcnew ServiceController; if ( sc ) { ... Section 15.4.6 in ECMA 372 (the C++/CLI spec)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.