".StartInfo.CreateNoWindow = True" creates a window!

C

Cooz

Hi everyone,

I have the following code (see my Run a DOS command line to examine RAR
contents-question below):

Dim myProcess As New Process()
With myProcess
With .StartInfo
.FileName = "cmd"
.Arguments = "/c " & thePath & "\unrar.exe lb -p" & psw & " " &
rarFile & " > " & _
thePath & "\raroutput.txt"
.CreateNoWindow = True
End With
.Start()
.WaitForExit()
.Dispose()
End With

which does exactly what it should, except that it flashes the command
prompt-window. Since I use this code in a loop, users that are prone to
migraine should stay away from my application. Which is a pity.

Why does "CreateNoWindow = True" not do what it promises? What can I do keep
the command prompt window hidden?

Thank you,
Cooz

I use VB 2005.
 
O

Onur Güzel

Hi everyone,

I have the following code (see my Run a DOS command line to examine RAR
contents-question below):

Dim myProcess As New Process()
With myProcess
     With .StartInfo
        .FileName = "cmd"
        .Arguments = "/c " & thePath & "\unrar.exe lb -p" & psw& " " &
rarFile & " > " & _
            thePath & "\raroutput.txt"
        .CreateNoWindow = True
    End With
    .Start()
    .WaitForExit()
    .Dispose()
End With

which does exactly what it should, except that it flashes the command
prompt-window. Since I use this code in a loop, users that are prone to
migraine should stay away from my application. Which is a pity.

Why does "CreateNoWindow = True" not do what it promises? What can I dokeep
the command prompt window hidden?

Thank you,
Cooz

I use VB 2005.

Hi,

It seems you're not passing StartInfo as argument to Start method. So,
you must:

Dim myprocess As New Process()
With myProcess

Dim info As New ProcessStartInfo
info.FileName = "cmd"
info.Arguments = "/c " & thepath & _
"\unrar.exe lb -p" & psw & " " & _
rarFile & " > " & _
thepath & "\raroutput.txt"

info.CreateNoWindow = True
' Pass StartInfo instance as argument
.Start(info)
.WaitForExit()
.Dispose()

End With

Hope this helps,

Onur Güzel
 
T

Tim Munro

Since you are using the .Startinfo sub structure rather than a separate
StartInfo object, you can add:

..WindowStyle = ProcessWindowStyle.Hidden either before or after your
..CreateNoWindow = True assignment.

--
Tim.

Hi everyone,

I have the following code (see my Run a DOS command line to examine RAR
contents-question below):

Dim myProcess As New Process()
With myProcess
With .StartInfo
.FileName = "cmd"
.Arguments = "/c " & thePath & "\unrar.exe lb -p" & psw & " " &
rarFile & " > " & _
thePath & "\raroutput.txt"
.CreateNoWindow = True
End With
.Start()
.WaitForExit()
.Dispose()
End With

which does exactly what it should, except that it flashes the command
prompt-window. Since I use this code in a loop, users that are prone to
migraine should stay away from my application. Which is a pity.

Why does "CreateNoWindow = True" not do what it promises? What can I do
keep
the command prompt window hidden?

Thank you,
Cooz

I use VB 2005.

Hi,

It seems you're not passing StartInfo as argument to Start method. So,
you must:

Dim myprocess As New Process()
With myProcess

Dim info As New ProcessStartInfo
info.FileName = "cmd"
info.Arguments = "/c " & thepath & _
"\unrar.exe lb -p" & psw & " " & _
rarFile & " > " & _
thepath & "\raroutput.txt"

info.CreateNoWindow = True
' Pass StartInfo instance as argument
.Start(info)
.WaitForExit()
.Dispose()

End With

Hope this helps,

Onur Güzel
 
O

Onur Güzel

Since you are using the .Startinfo sub structure rather than a separate
StartInfo object, you can add:

.WindowStyle = ProcessWindowStyle.Hidden either before or after your
.CreateNoWindow = True assignment.

--
Tim.










Hi,

It seems you're not passing StartInfo as argument to Start method. So,
you must:

Dim myprocess As New Process()
        With myProcess

            Dim info As New ProcessStartInfo
            info.FileName = "cmd"
            info.Arguments = "/c " & thepath & _
            "\unrar.exe lb -p" & psw & " " & _
            rarFile & " > " & _
            thepath & "\raroutput.txt"

            info.CreateNoWindow = True
           ' Pass StartInfo instance as argument
            .Start(info)
            .WaitForExit()
            .Dispose()

        End With

Hope this helps,

Onur Güzel

Good point, though he may set WindowStyle property to Hidden, also
setting UseShellExecute property to False "should" be used in
conjunction with CreateNoWindow property by setting it "True" if it's
launching from command-prompt to avoid a new window as follows:

Dim myprocess As New Process()
With myprocess

Dim info As New ProcessStartInfo
info.FileName = "cmd"
info.Arguments = "/c " & thepath & _
"\unrar.exe lb -p" & psw & " " & _
rarFile & " > " & _
thepath & "\raroutput.txt"
info.UseShellExecute = False
info.CreateNoWindow = True
' Pass StartInfo instance as argument
.Start(info)

End With

http://blogs.msdn.com/jmstall/archive/2006/09/28/CreateNoWindow.aspx

HTH,

Onur Güzel
 
C

Cooz

Hi Tim,

Yep... that's what I found out myself not too long after I posted my
question... I shouldn't be too quick to consult the discussion groups.

Thank you for your participation.
Cooz
 
C

Cooz

Hi Onur,

I haven't tried your suggestion; the one Tim came up with already did the
trick.
But thank you for your contributions.

Cooz
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top