Re: Calling CreateProcessWithLogonW
From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 07/15/04
- Previous message: Joe Kaplan \(MVP - ADSI\): "Re: Access File Share from ASP.NET using Unmanaged Code"
- In reply to: Benjamin Bittner: "Re: Calling CreateProcessWithLogonW"
- Next in thread: Alstersjo: "Back to Original question"
- Reply: Alstersjo: "Back to Original question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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
>
>
- Previous message: Joe Kaplan \(MVP - ADSI\): "Re: Access File Share from ASP.NET using Unmanaged Code"
- In reply to: Benjamin Bittner: "Re: Calling CreateProcessWithLogonW"
- Next in thread: Alstersjo: "Back to Original question"
- Reply: Alstersjo: "Back to Original question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|