Process.StandardInput.WriteLine not working under Vista?

  • Thread starter Thread starter SurturZ
  • Start date Start date
S

SurturZ

The following code used to work. It starts up notepad and types a few lines.
What am I doing wrong? I'm using VB.NET 2005 under Vista. It starts notepad
okay, but it can't 'type' into it.


'demonstrate "typing" into notepad
Dim psiProcessStartInfo As New ProcessStartInfo
With psiProcessStartInfo
.Arguments = "" 'command line arguments
.CreateNoWindow = False
.ErrorDialog = False
.FileName = "notepad.exe"
.LoadUserProfile = False
.RedirectStandardError = False
.RedirectStandardInput = True
.RedirectStandardOutput = False
.UseShellExecute = False 'this must be false for
input/output/error redirection
.WorkingDirectory = ""
End With
Using prc As Process = Process.Start(psiProcessStartInfo)
MsgBox("")
prc.StandardInput.WriteLine("This line added by ProcessMgmtDemo")
prc.StandardInput.WriteLine("This line added by ProcessMgmtDemo")
prc.StandardInput.WriteLine("This line added by ProcessMgmtDemo")
End Using
 
The following code used to work. It starts up notepad and types a few lines.
What am I doing wrong? I'm using VB.NET 2005 under Vista. It starts notepad
okay, but it can't 'type' into it.

        'demonstrate "typing" into notepad
        Dim psiProcessStartInfo As New ProcessStartInfo
        With psiProcessStartInfo
            .Arguments = "" 'command line arguments
            .CreateNoWindow = False
            .ErrorDialog = False
            .FileName = "notepad.exe"
            .LoadUserProfile = False
            .RedirectStandardError = False
            .RedirectStandardInput = True
            .RedirectStandardOutput = False
            .UseShellExecute = False 'this must be false for
input/output/error redirection
            .WorkingDirectory = ""
        End With
        Using prc As Process = Process.Start(psiProcessStartInfo)
            MsgBox("")
            prc.StandardInput.WriteLine("This line added by ProcessMgmtDemo")
            prc.StandardInput.WriteLine("This line added by ProcessMgmtDemo")
            prc.StandardInput.WriteLine("This line added by ProcessMgmtDemo")
        End Using

Why are you trying to open and manipulate Notepad instead of just
writing to a file and then opening it in Notepad?

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
Back
Top