Creating a Process to live after logoff

Creating a Process to live after logoff

Post by John Olive » Thu, 03 Jul 2003 15:48:58



I have a requirement to execute a program that will run
after the user has logged off.

Although the simple answer is to execute it under a
specific User Account, I am restricted to running it under
the initiators account (the information is required by the
executed program and I dont have the luxury of modifying
the code).

I've tried to set the STARTUPINFO properties
  dwFlags = 1
  wShowWindow = 0

and also tried to set the lpDesktop property to both NULL
and empty string.  Neither of these did anything different.

Since I got nowhere with this, I attempted
CreateProcessAsUser().

    lSuccess = OpenProcessToken(GetCurrentProcess,
TOKEN_ALL_ACCESS, hProcessToken)

    With udtStartInfo
        .cb = LenB(udtStartInfo)              'Size of the
structure
        .lpReserved = &H0&                  'Reserved
        .cbReserved2 = &H0&                 'Reserved
        .dwFlags = 1         'Use the wShowWindow parameter
        .wShowWindow = 0
    End With

    udtProcessAttributes.nLength = Len
(udtProcessAttributes)
    udtThreadAttributes.nLength = Len(udtThreadAttributes)

    lSuccess = CreateProcessAsUser( _
                            hProcessToken, _
                            "c:\temp\TestProc.exe", _
                            vbNullString, _
                            udtProcessAttributes, _
                            udtThreadAttributes, _
                            False, _
                            0&, _
                            0&, _
                            vbNullString, _
                            udtStartInfo, _
                            udtProcessInformation)

Here, I get the error
  1314: A required privilege is not held by the client.

I have also attempted the LogonUser() call, and get the
same error returned.

I read MSDN and still cannot come up with anything.

Can anyone help?

John

 
 
 

Creating a Process to live after logoff

Post by Paul Hickma » Thu, 03 Jul 2003 21:01:34


Have you looked at using the Windows scheduler to start
the process instead of the API - it might be possible.

 
 
 

Creating a Process to live after logoff

Post by Jim Barr » Thu, 03 Jul 2003 21:09:36



> I have a requirement to execute a program that will run
> after the user has logged off.

On Win9x you can call RegisterServiceProcess. On NT/2000/XP you will need to write a service program.

--
Jim Barry, MVP for Windows SDK

 
 
 

Creating a Process to live after logoff

Post by Henk Devo » Sat, 05 Jul 2003 05:58:18


Or alternatively, you could write a service just for the creation of
processes.
Let your app pass the path and user name etc. to the service, let the
service execute LogonUser etc.



> I have a requirement to execute a program that will run
> after the user has logged off.

On Win9x you can call RegisterServiceProcess. On NT/2000/XP you will need to
write a service program.

--
Jim Barry, MVP for Windows SDK

 
 
 

1. Call 1-800-856-2469, LIVE LIVE LIVE 809-474-7588 code2099

18+, 24hours, rates as low as $0.38/min

Hot, Young women want it NOW ----011-592-247-681
Gay, Bi, Bi-curious guys at -----809-474-7604
************************************************
************************************************
************************************************
************************************************

comp.sys.next.hardware

2. Case that can hold a palm Vx and cell phone

3. Call 1-800-856-2469, LIVE LIVE LIVE 809-474-7588 code639

4. How to fetch multiple arg?

5. Call 1-800-856-2469, LIVE LIVE LIVE 809-474-7588 code643

6. +3, .dsk

7. Call 1-800-856-2469, LIVE LIVE LIVE 809-474-7588 code664

8. http-speech-telephony

9. Call 1-800-856-2469, LIVE LIVE LIVE 809-474-7588 code2895

10. Call 1-800-856-2469, LIVE LIVE LIVE 809-474-7588 code6391

11. Call 1-800-856-2469, LIVE LIVE LIVE 809-474-7588 code499

12. Call 1-800-856-2469, LIVE LIVE LIVE 809-474-7588 code4438

13. Can't install Messenger - "error creating process"