Link to home
Start Free TrialLog in
Avatar of jkaios
jkaiosFlag for Marshall Islands

asked on

VB Translation of PSSHUTDOWN.EXE

Hello Experts!

Does anybody know of a VB translation of Mark Russinovich's PSSHUTDOWN.EXE program?

I want to incorporate this program's functionality into my own VB application.  I've found the VB translation of his another utility program PSLOGGEDON.EXE at http://www.mvps.org/access/api/api0062.htm, in which the original source code (in C/C++) was available for download from www.sysinternals.com.  So, I'm wondering if the aforementioned program (written in C/C++) has been translated into VB.

In short, I want my VB app to do exactly the same thing.  That is, be able to support all following 4 types of operation on a remote machine:

 1. Logoff
 2. Shutdown
 3. Reboot
 4. Poweroff

I already knew and have tried both following Win32 APIs:

 1. ExitWindowsEx - this supports all 4 above types of operation, except that it ONLY apples to the LOCAL machine.
 2. InitiateSystemShutdownEx - this seems to be the one I wanted, except that it DOES NOT have or support the "logoff" method.

I could include the PSSHUTDOWN.EXE and create a MSI installation package to be distributed along with my compiled app so that I can use the "shell" function, but I just want my app to be a pure, stand-alone application.

Any help would be greatly appreciated.
Avatar of Shane Russell
Shane Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of jkaios

ASKER

Thanks gecko.  That uses the InitiateSystemShutdown API, which DOES NOT support the "Logoff" operation.

In fact, somebody (shijusn) already provided this link to my previous question at: https://www.experts-exchange.com/questions/22038122/Logoff-Poweroff-Reboot-or-Shutdown-a-Remote-machine-using-API.html
I did mention wmi above but I havent had much of a chance lately to have a look around for examples on how to remotely restart, shutdown, log off etc using wmi but will have a look tommorow , so if that wmiRescue zip does not help then post back and I will post back with some wmi examples :)
Avatar of jkaios

ASKER

Thanks EDDYKT, but what I preferred was to use API instead due to the fact that when using the WMI's "Win32Shutdown" method of the "Win32_OperatingSystem" class on Windows XP Service Pack 2, it really slows down the process, and most of the time fails when the Firewall is turned on.

In fact, I've already developed a fully functional app (using WMI) that does this, but the problem started when Windows XP SP2 was released.  Until now it still works, however, it is REALLY slow as a result of the heavy security in XP SP2.  Note that this problem does not apply to W2K machines.

The reason why I wanted a translation of the PSSHUTDOWN.EXE is because it bypasses those XP security.  The built-in utility (Shutdown.exe) that came with XP and Server 2003 is great, except that it does not support the "logoff" method.

I've been wondering what sort of or combination of API's did Mark Russinovich use in his wonderful PSSHUTDOWN.EXE program?
Avatar of jkaios

ASKER

I just found out the trick that PSSHUTDOWN.EXE uses is that it quietly copies a file named PSSDNSVC.EXE to the hidden ADMIN$ share on the target machine (either in "C:\Windows" or "C:\WinNT" depending on target machine's OS).

This file is then installed on the target machine as a service, and clearly, runs as a client/server application.  After the requested action has been performed on the target machine, then calling program (PSSHUTDOWN.EXE) then deletes PSSDNSVC.EXE from the target machine.  The Event Viewer shows all the traces when this service was installed and removed.

I thought there were some other fancy (undocumented) API's that support remote logoff other than the InititateSystemShutdown.  Perhaps, Mark could be using a different technique other than what I assumed, who knows.  The guy is a genius and he even has a very good article on Win32 APIs versus Native APIs.

Therefore, I 'm gonna ask the Moderator to close this question.
ASKER CERTIFIED SOLUTION
Avatar of PashaMod
PashaMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial