How do I change the current user logged in the NT box programatically from the client without rebooting it?

The short answer is that you can’t. If you want to change the current logged-on user, you must logoff of NT (not necessarily reboot) and logon as the new user. The code below will do that. If what you want to do is change the user for a specific proces*, then there are other options. The API option is good, but goes fairly deeply into actively VB-unfriendly calls, involving logging on to the server or local machine programmatically via LogonUser, then programmatically set each process to this new set of user credentials. If you only want to run one or two programs with enhanced security, you can use the SU.EXE program (available with the NT Resource Kit). This creates some security holes, but it is a possible solution.

Private Const EWX_LOGOFF As Long = 0&Declare Function ExitWindowsEx _   Lib "user32" _   (ByVal uFlags As Long, _    ByVal dwReserved As Long) As LongPublic Sub LogOff()   Dim p_lngRtn            As Long   Dim p_lngFlags          As Long      p_lngFlags = EWX_LOGOFF   p_lngRtn = ExitWindowsEx(p_lngFlags, 0&)End Sub

See also - an AI reverse image search platform

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist