I plan an application in VB.NET that is capable of shutting down remote Win and Linux systems via OS intrinsic RPC calls. (No hacking, just a useful tool application for my own use. )

To be precise, most of the surrounding code is already done - only the shutdown part is not yet done with RPC, in the current pre-alpha I spwan sysinternal's psshutdown.exe instead for Win machines and rolled my own rudimentary Telnet client for the others. (that psshutdown tool is not bad at all, but I want to incorporate the function into my code and not incorporate other folks tools, and for the Linux client I don't want to knit my own SSH ... ).

I know this is possible with RPC calls, i.e. on an Linux system I can run the command

Code:
net rpc SHUTDOWN -C "some comment here" -f -I x.x.x.x -U user_name%password"
to shut down a windows system if the given user has appropriate rights and the Linux box runs Samba.. I presume that this works for shutting down linux systems (running Samba), too.

On Win systems (XP+) I can use the shutdown command, but
  • This can't supply a different user/password info, and
  • possibly doesn't work for Linux targets, because
  • it presumably uses another way to initiate shutdown (i.e. WMI)


Even while googling around for hours, I havn't found any helpful code example for that. There's a bit of documentation for the windows part here, but that contains no helpful examples, and some infor might be buried in the C sources of Samba. What I need is a simple (VB.NET) class/method that initiates shutdown (with the necessary options ... normal/forced, grace period, etc., user, password) for remote Win and Linux machines:
Code:
Public Class RemoteShutdown

    Public Sub InitiateRemoteShutdownWin(target As String, user As String, _
             password As String, forced as boolean, graceSeconds As Integer) _ 
             As Boolean
        (...)
    End Sub

    Public Sub InitiateRemoteShutdownLinux(target As String, user As String, _
             password As String, forced as boolean, graceSeconds As Integer) _ 
             As Boolean
        (...)
    End Sub

End Class
If this is not possible with VB.NET standard built-ins, I would appreciate any other way that I might incorporate into my VB.NET software.

Greetings

Ovaron