Run batch files with impersonation

Discussion in 'ASP .Net Security' started by dd.squad@gmail.com, Aug 24, 2006.

  1. Guest

    When creating a new process, the aspnet worker process always runs it
    under the ASPNET user instead of the user that is being impersonated.
    After some research, I got around this by invoking the
    CreateProcessAsUser win api call. That works ok for executables, but
    trying to run batch files gave me an Access is Denied return code (5).
    This is apparently because creating a process from a .bat file actually
    uses c:\windows\system32\cmd.exe. So I gave the impersonated user
    account permission to run cmd.exe, but it still returns with
    -1073741502 (0xC0000142 in hex) which has something to do with dll's
    not initializing. Looks to me like cmd.exe may require access to some
    system dll's that the impersonated user has no access to. If I don't
    impersonate, and just let it run with the ASPNET user, it works. We
    have a large number of batch files that really need to be run from
    impersonated asp.net app. Does anyone have any insight into how to
    make this work?
    , Aug 24, 2006
    #1
    1. Advertising

  2. MikeS Guest

    Did you change the command being executed to be something like "cmd.exe
    /c myJob.bat" ?

    Also, since this is .NET forum not win32,

    It looks like you can use a System.Diagnostics.Process and it's
    StartInfo property to specifiy the credentials to run with.
    MikeS, Aug 26, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike John

    How to run a batch file.

    Mike John, Jul 23, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    402
    Saravana
    Jul 23, 2003
  2. Elroyskimms
    Replies:
    0
    Views:
    3,435
    Elroyskimms
    Jul 18, 2006
  3. Replies:
    7
    Views:
    5,863
    Dennis Lee Bieber
    Jul 26, 2005
  4. Chris Rebert

    Re: Converting .py files to batch files.

    Chris Rebert, Sep 15, 2008, in forum: Python
    Replies:
    0
    Views:
    377
    Chris Rebert
    Sep 15, 2008
  5. Matias Surdi

    Re: Converting .py files to batch files.

    Matias Surdi, Sep 15, 2008, in forum: Python
    Replies:
    4
    Views:
    504
Loading...

Share This Page