Remotely start windows service using java

View: New views
2 Messages — Rating Filter:   Alert me  

Remotely start windows service using java

by Simon Sekat :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear all,

I am very excited with learning the jcifs component in the past few
days.  Made some progress and I feel it's very promising to be able to
accomplish my task: research how to remotely start Windows Service
using Java.

I learned that I should be using the predefined svcctl pipe.

The code should be something like:

SmbNamedPipe pipe = new SmbNamedPipe( "smb://server/IPC$/PIPE/svcctl",
        SmbNamedPipe.PIPE_TYPE_RDWR | SmbNamedPipe.PIPE_TYPE_CALL );
OutputStream out = pipe.getNamedPipeOutputStream();
InputStream in = pipe.getNamedPipeInputStream();

I think I should the operation StartServiceW of such pipe
(http://www.hsc.fr/ressources/articles/win_net_srv/msrpc_svcctl.html).

I need guidance with what I should do next?  What to write to the
outputstream which would trigger the start of, say, the server
process?

--
Simon
西门烧雪

Re: Remotely start windows service using java

by Michael B Allen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That's an MSRPC interface. You need to find the IDL for the
StartService call, translated it into a "stub" with midlc and then use
it with DcerpcHandle.sendrecv. A good example of how to do this would
be jcifs.smb.SID.getServerSid maybe. Google for svcctl.idl and you can
probably find enough of the IDL to get started. However, MS has
probably released this information in their Windows Server Protocol
documents. That would be the definitive reference.

Mike

2009/9/21 西门烧雪 Simon <sekatsimon@...>:

> Dear all,
>
> I am very excited with learning the jcifs component in the past few
> days.  Made some progress and I feel it's very promising to be able to
> accomplish my task: research how to remotely start Windows Service
> using Java.
>
> I learned that I should be using the predefined svcctl pipe.
>
> The code should be something like:
>
> SmbNamedPipe pipe = new SmbNamedPipe( "smb://server/IPC$/PIPE/svcctl",
>        SmbNamedPipe.PIPE_TYPE_RDWR | SmbNamedPipe.PIPE_TYPE_CALL );
> OutputStream out = pipe.getNamedPipeOutputStream();
> InputStream in = pipe.getNamedPipeInputStream();
>
> I think I should the operation StartServiceW of such pipe
> (http://www.hsc.fr/ressources/articles/win_net_srv/msrpc_svcctl.html).
>
> I need guidance with what I should do next?  What to write to the
> outputstream which would trigger the start of, say, the server
> process?
>
> --
> Simon
> 西门烧雪
>



--
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/