Link to home
Start Free TrialLog in
Avatar of Mel Brooks
Mel Brooks

asked on

Logoff.exe not working on server 2019

I have included the following code on several terminal servers to log a user off when closing the application.
Shell "logoff.exe", vbNormalFocus

I now have a server where this code gives the error "Invalid procedure call".
I can replace the code to open Notepad like this:
Shell "Notepad.exe", vbNormalFocus
and that works fine to open the application.  I have tried including the full path to logoff.exe and dropping it in a batch file and running it from there. Still no luck.
Any suggestions?

This is VBA code inside a MS Access 2010-2019 application
Avatar of Amir Azhdari
Amir Azhdari
Flag of United States of America image

Have you tried the following:

Set oSShell = CreateObject("WScript.Shell") 
WScript.Sleep 1000
oSShell.Run "logoff.exe", 0, False

Open in new window

Is the .exe available?

Can you manually run it from the command line?

If so, did it require admin level privilege to execute it?

Usually an "Invalid procedure call", means you have an argument wrong or of the wrong data type.

Avatar of Mel Brooks
Mel Brooks


I get error 424 on line 2. Object required
If I rem out line 2, then on line 3 I get error 70 permission denied.

I can drop logoff.exe into a batch file.  As a domain user, I can double-click the file and it logs me off

Probably is a permissions issue.
Note sure if it's permissions....a user should be able to logoff.

Interestingly enough though, when I tried it here on a Win 10 machine, I could execute it from the command line without issue, but if I used Shell() out of VBA, I would get a "File not found", even specifying the full path.

So Win 10 at least is playing some games behind the scenes.  I haven't had a chance though to play with it further.

Well I'm glad it's not just me.
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I forgot all about the shutdown command.  That seems to be working much better.