How can I force a LockWorkstation from a Windows Service on Vista?

M

Malignonne

Hello,
I have written a Credential Provider which requires a secure token to be
present. This works fine. I have written a Windows Service which periodically
scans for the secure token presence. This works fine.

HOWEVER ....

What I would like to be able to do is to lock the workstation (go back to
the logon screen) if my Windows Service notices that the secure token is no
longer present.

How can I do this (I've been trawling through the web and haven't found
anything I can use).

I've tried running the Windows Service both as a User and as a LocalService.

Any suggestions would be very gratefully received!
 
M

Malignonne

Thanks Mark,

That was one I had already tried!

The command works fine from a console window, but not from a Windows
Service. For example:

HINSTANCE x = ShellExecute(NULL, NULL, "rundll32.exe",
"user32.dll,LockWorkStation", NULL, 0);

returns x = 42, which indicates success. However, the workstation is not
locked.

It looks like a security problem of some sort (I've tried running the
service as Local Server and a Remote Service too, but there is no change)

Regards
Ben
 
M

Malignonne

This doesn't work either, even if I put it in a bat file and run that.

I agree that it is a rights problem.

The problem is how do I resolve it?!
 
M

Malignonne

Still no joy, I'm afraid. Trying to run the shortcut from the service
returns an error of 2.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top