HowTo start/stop a service on a remote computer

  • Thread starter Thread starter schaf
  • Start date Start date
S

schaf

Hi all!
I'm still trying to start/stop a service on a remote computer. (I
promiss that's the last new post because of this problem from my side)

My situation:
I've an application running under the user paul (pw:paul123) on the
computer A in the domain ABC. This application should stop / start a
service, which is running on computer B (in workgroup ABCWG (NOT IN
DOMAIN ABC)). On the computer B I have a user administrator (pw:
adminTest) and a user TestUser (pw: testuser). Both of this user does
not exist in domain ABC

I tried to get the user credentials of a user on computer B by using
LogonUser. I tried this with both users on computer B, but it does not
work. If I rename the TestUser into paul on computer B I get an error
message, but I also get the access token.

Code and better description of this problem could be seen in:
http://groups.google.ch/group/micro...ff260f9880d/4ce31c968f8d92ab#4ce31c968f8d92ab

So now I'm not shure, if I'm on the right way to start/stop a service
on a remote computer. If this is the right way, which requirements must
be fulfilled ?

Thanks and regards
Marcel Hug
 
| Hi all!
| I'm still trying to start/stop a service on a remote computer. (I
| promiss that's the last new post because of this problem from my side)
|
| My situation:
| I've an application running under the user paul (pw:paul123) on the
| computer A in the domain ABC. This application should stop / start a
| service, which is running on computer B (in workgroup ABCWG (NOT IN
| DOMAIN ABC)). On the computer B I have a user administrator (pw:
| adminTest) and a user TestUser (pw: testuser). Both of this user does
| not exist in domain ABC
|

Use the right tools for this, that is System.Management and WMI, no need for
LogonUser and impersonation stuff.


| I tried to get the user credentials of a user on computer B by using
| LogonUser. I tried this with both users on computer B, but it does not
| work. If I rename the TestUser into paul on computer B I get an error
| message, but I also get the access token.
|

I don't get it really, if LogonUser fails you can't possibly get an access
token.

| Code and better description of this problem could be seen in:
|
http://groups.google.ch/group/micro...ff260f9880d/4ce31c968f8d92ab#4ce31c968f8d92ab
|

This is only a part of the code, not usable anyway.

| So now I'm not shure, if I'm on the right way to start/stop a service
| on a remote computer. If this is the right way, which requirements must
| be fulfilled ?
|

What happens if you first establish a network session with the remote server
(using net use \\... /user:....) and after that, try to stop/start a service
remotely using the services applet?

Note that you should delete the network session before you try again using
LogonUser/Impersonate, else you will use the established session to access
the remote resource instead of the access token obtained (or not) by
LogonUser.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top