Jump to content

Issue using CreateEnvironmentBlock. Help :)

Recommended Posts

I have a script (Attached) that does the following:

1. Adds a user to have logon as service rights using win32 calls. This works fine.

2. Logs on that user using win32 api LogonUser (LogonType=5). This works fine.

3. Loads the users profile using LoadProfile win32 API. This works fine.

4. Creates an environment block for the user using the users token. This doesn't appear to work. The function returns 1 (true) but the pointer to the block that should be returned appears to be empty. The process is created with the environment from the parent process.

5. Runs a process as the user and waits. This works fine

6. Unloads the user profile and returns the code from the process launched in step 5.

I can't for the life of me figure out why CreateEvironmentBlock is returning true, but not giving me an environment block. I need to have the process have the environment of the user instead of an inherited environment.

I thought initially it had something to do with win32 data types. LogonUser returns a pointer to a handle (PHANDLE), but CreateEnvironmentBlock wants a HANDLE.

Can anyone look over this script and give me some thoughts?

Edited by Lunchbox
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...