Re: Calling CreateProcessWithLogonW

From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 07/15/04

  • Next message: N S S: "ASP.NET Impersonating a Certain User At Run time"
    Date: Thu, 15 Jul 2004 09:54:54 -0500
    
    

    I have no idea why that isn't working. I'd suggest trying it from a console
    application where you can set it to create a window and add some
    thread.sleep statements to see if you can actually see what's going on.
    Maybe it will be obvious.

    You might also try calling runas directly instead of calling it through cmd.

    Joe K.

    "Benjamin Bittner" <benjamin_bittner[a_t]nospam.web.de> wrote in message
    news:eoyqMDkaEHA.3684@TK2MSFTNGP09.phx.gbl...
    > Hallo Joe,
    > "Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com>
    schrieb
    > im Newsbeitrag news:uSGEWIOaEHA.3988@tk2msftngp13.phx.gbl...
    > > You will need to redirect the input and output streams of the Process
    > class
    > > so that you can send and receive text using them. This might work
    better
    > if
    > > you call runas directly instead of calling it from a VBScript, but
    either
    > > might work.
    > >
    > > To redirect the streams, you need to set UseShellExecute to False and
    set
    > > RedirectStandardInput and RedirectStandardOutput to true. Then, you
    read
    > > and write to the streams on the Process instance.
    > >
    > > Joe K.
    > >
    >
    > Okay this is what i got so far:
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > Dim psCscript As Process = New Process()
    > With psCscript
    > .StartInfo.RedirectStandardInput = True
    > .StartInfo.RedirectStandardOutput = True
    > .StartInfo.UseShellExecute = False
    > .StartInfo.FileName = "cmd"
    > .StartInfo.Arguments = " /C runas /user:TEST\Administrator
    ""cmd.exe
    > /C C:\test_webs\tmpl.loopline.de\docs\mkw3site.vbs -r
    > C:\test_webs\tmpl.test.de -t xyzclient.test.de -o 8080"""
    > End With
    > psCscript.Start()
    > Dim myStreamWriter As StreamWriter = psCscript.StandardInput
    > myStreamWriter.WriteLine("myPassword")
    > myStreamWriter.Close()
    > psCscript.WaitForExit()
    > lblTest.Text = "Process ended: " & psCscript.ExitTime & "<br>" & _
    > "Exit Code: " & psCscript.ExitCode
    > lblTest.Text &= "<br> File Name: " & psCscript.StartInfo.FileName
    > lblTest.Text &= "<br> Arguments: " & psCscript.StartInfo.Arguments
    > psCscript.Close()
    > End Sub
    >
    > The result page displays:
    >
    > Process ended: 15.07.2004 09:42:12
    > Exit Code: 0
    > File Name: cmd
    > Arguments: /C runas /user:TEST\Administrator "cmd.exe /C
    > C:\test_webs\tmpl.loopline.de\docs\mkw3site.vbs -r
    > C:\test_webs\tmpl.test.de -t xyzclient.test.de -o 8080"
    >
    > But nothing happens. If i use this line:
    >
    > cmd /C runas /user:TEST\Administrator "cmd.exe /C
    > C:\test_webs\tmpl.loopline.de\docs\mkw3site.vbs -r
    > C:\test_webs\tmpl.test.de -t xyzclient.test.de -o 8080"
    >
    > with Start > Execute on the TEST machine, it works.
    > So i know there isnt much to track down the error, but maybe someone has
    an
    > idea how it could be tracked down.
    >
    > regards benni
    >
    >


  • Next message: N S S: "ASP.NET Impersonating a Certain User At Run time"

    Relevant Pages

    • Re: ADFS Proxy Error
      ... Thx Joe, ... The redirect from the account FS to the resource FS is a POST redirect of ... An unhandled exception has occurred. ...
      (microsoft.public.windows.server.active_directory)
    • Re: ASP .NET Redirect Question.
      ... it actually should redirect back to my calling page and ... returning to my calling page. ... "Scott Allen" wrote: ... >>it needs a dedicated IP address, if my local workstation isn't sufficient. ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: Calling CreateProcessWithLogonW
      ... > You will need to redirect the input and output streams of the Process ... Private Sub Page_Load(ByVal sender As System.Object, ... Dim psCscript As Process = New Process ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: how to get Process object from a thread (Runnable)
      ... I want to get a Process object just for this part of one of my ... within the JVM is the JVM itself. ... need a Process to get these Streams. ... so you can't redirect them just for some code executed by ...
      (comp.lang.java.programmer)
    • Re: Calling CreateProcessWithLogonW
      ... You will need to redirect the input and output streams of the Process class ... > But i dont know how to react on the password prompt. ...
      (microsoft.public.dotnet.framework.aspnet.security)