Connecting Tech Pros Worldwide Forums | Help | Site Map

Process Check loop

Dubya
Guest
 
Posts: n/a
#1: Nov 21 '05
Hello All

I have the following code below that starts an external process batch file.
I would like to have the application display a dialog box confirming that the
process has ended. When I run the code below, I get an exception error

An unhandled exception of type 'System.InvalidOperationException' occurred
in system.dll

Additional information: No process is associated with this object.

Here is the code

Public Sub UploadFile()
Dim p As New Process
p.Start("c:\ofac\ftpUpload.cmd")
Do While p.HasExited = False <-- Here is where the error occurs
Loop
If p.HasExited = True Then
MsgBox("File successfully uploaded", MsgBoxStyle.Information,
"OFAC File Generator")
End If

End Sub

--
Freedom isn't free... but the United States Marine Corps will pay most of
your share !!! Semper Fi!!

Crouchie1998
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Process Check loop


The 'cmd' file isn't a process.

Processes are usually 'exe' files.

Crouchie1998
BA (HONS) MCP MCSE


Kaoru Kodaka
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Process Check loop


Dear Crouchie1998,

On Tue, 7 Jun 2005 20:40:17 +0100
"Crouchie1998" <crouchie1998@spamcop.net> wrote:
[color=blue]
> The 'cmd' file isn't a process.
>
> Processes are usually 'exe' files.[/color]

This means He/She should use below.

p.Start("%COMSPEC% c:\ofac\ftpUpload.cmd")

---
MVP kaok = MVP.ChangeMvpCategory("for C# 2004-2005.");
kaok.Web = "http://www.antoine.st/";

John Wildes
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Process Check loop


I'm sorry but that's not correct either, if I use that, i get a SYSTEM
CANNOT FIND FILE exception.

Any more ideas.

thanks for the help
john

"Kaoru Kodaka" <kaok@venus.dti.ne.jp> wrote in message
news:20050608094429.8C41.KAOK@venus.dti.ne.jp...[color=blue]
> Dear Crouchie1998,
>
> On Tue, 7 Jun 2005 20:40:17 +0100
> "Crouchie1998" <crouchie1998@spamcop.net> wrote:
>[color=green]
>> The 'cmd' file isn't a process.
>>
>> Processes are usually 'exe' files.[/color]
>
> This means He/She should use below.
>
> p.Start("%COMSPEC% c:\ofac\ftpUpload.cmd")
>
> ---
> MVP kaok = MVP.ChangeMvpCategory("for C# 2004-2005.");
> kaok.Web = "http://www.antoine.st/";
>[/color]


Kaoru Kodaka
Guest
 
Posts: n/a
#5: Nov 21 '05

re: Process Check loop


Dear John,

I'm sorry, I didn't know the Start method doesn't extract
environment variables.

You can use below code instead of it.

p.Start("cmd.exe c:\ofac\ftpUpload.cmd")

If target OS is Windows 9x, You have to use "command.com"
instead of "cmd.exe".

I hope this will help you.



On Wed, 8 Jun 2005 14:33:13 -0500
"John Wildes" <jwildes@gmail.com> wrote:
[color=blue]
> I'm sorry but that's not correct either, if I use that, i get a SYSTEM
> CANNOT FIND FILE exception.
>
> Any more ideas.
>
> thanks for the help
> john
>
> "Kaoru Kodaka" <kaok@venus.dti.ne.jp> wrote in message
> news:20050608094429.8C41.KAOK@venus.dti.ne.jp...[color=green]
> > Dear Crouchie1998,
> >
> > On Tue, 7 Jun 2005 20:40:17 +0100
> > "Crouchie1998" <crouchie1998@spamcop.net> wrote:
> >[color=darkred]
> >> The 'cmd' file isn't a process.
> >>
> >> Processes are usually 'exe' files.[/color]
> >
> > This means He/She should use below.
> >
> > p.Start("%COMSPEC% c:\ofac\ftpUpload.cmd")
> >
> > ---
> > MVP kaok = MVP.ChangeMvpCategory("for C# 2004-2005.");
> > kaok.Web = "http://www.antoine.st/";
> >[/color]
>[/color]


---
MVP kaok = MVP.ChangeMvpCategory("for C# 2004-2005.");
kaok.Web = "http://www.antoine.st/";

John Wildes
Guest
 
Posts: n/a
#6: Nov 21 '05

re: Process Check loop


Kaoru,

I tried this as well before you posted it, and it seems that I cannot pass
an executable with parameters, I even created a .vbs script file, which
calls the cmd file from VB.net and it stills gives me an Exception either,
FILE NOT FOUND when I'd enter p.Start("wscript.exe
c:\OFAC\ftpFileUpload.vbs") or p.Start("cmd.exe "c:\OFAC\fileUpload.cmd")

The process runs when I just call the cmd or the vbs file, but what I want
to happen is to report back to the application that it has finished and then
notify the user that it has finished.

thanks for the help
john

"Kaoru Kodaka" <kaok@venus.dti.ne.jp> wrote in message
news:20050609095229.5C90.KAOK@venus.dti.ne.jp...[color=blue]
> Dear John,
>
> I'm sorry, I didn't know the Start method doesn't extract
> environment variables.
>
> You can use below code instead of it.
>
> p.Start("cmd.exe c:\ofac\ftpUpload.cmd")
>
> If target OS is Windows 9x, You have to use "command.com"
> instead of "cmd.exe".
>
> I hope this will help you.
>
>
>
> On Wed, 8 Jun 2005 14:33:13 -0500
> "John Wildes" <jwildes@gmail.com> wrote:
>[color=green]
>> I'm sorry but that's not correct either, if I use that, i get a SYSTEM
>> CANNOT FIND FILE exception.
>>
>> Any more ideas.
>>
>> thanks for the help
>> john
>>
>> "Kaoru Kodaka" <kaok@venus.dti.ne.jp> wrote in message
>> news:20050608094429.8C41.KAOK@venus.dti.ne.jp...[color=darkred]
>> > Dear Crouchie1998,
>> >
>> > On Tue, 7 Jun 2005 20:40:17 +0100
>> > "Crouchie1998" <crouchie1998@spamcop.net> wrote:
>> >
>> >> The 'cmd' file isn't a process.
>> >>
>> >> Processes are usually 'exe' files.
>> >
>> > This means He/She should use below.
>> >
>> > p.Start("%COMSPEC% c:\ofac\ftpUpload.cmd")
>> >
>> > ---
>> > MVP kaok = MVP.ChangeMvpCategory("for C# 2004-2005.");
>> > kaok.Web = "http://www.antoine.st/";
>> >[/color]
>>[/color]
>
>
> ---
> MVP kaok = MVP.ChangeMvpCategory("for C# 2004-2005.");
> kaok.Web = "http://www.antoine.st/";
>[/color]


John Wildes
Guest
 
Posts: n/a
#7: Nov 21 '05

re: Process Check loop


I did figure out how to pass arguments to the process

Public Sub UploadFile()

Dim p As New Process

Dim fileName As String

Dim args As String

fileName = "wscript.exe"

args = "C:\OFAC\ftpShellVBS.vbs"

p.StartInfo.FileName = fileName

p.StartInfo.Arguments = args

p.Start()

End Sub



Using the StartInfo.Arguments for the Process you can pass arguments like specifiing the script file to be run for WScript. It will also properly pass the HasExited part of my code, unfortunately it is at the WScriptLevel and not CMD level where my batch file is running. Just an FYI

john



"John Wildes" <jwildes@gmail.com> wrote in message news:uWh62BQbFHA.2416@TK2MSFTNGP09.phx.gbl...[color=blue]
> Kaoru,
>
> I tried this as well before you posted it, and it seems that I cannot pass
> an executable with parameters, I even created a .vbs script file, which
> calls the cmd file from VB.net and it stills gives me an Exception either,
> FILE NOT FOUND when I'd enter p.Start("wscript.exe
> c:\OFAC\ftpFileUpload.vbs") or p.Start("cmd.exe "c:\OFAC\fileUpload.cmd")
>
> The process runs when I just call the cmd or the vbs file, but what I want
> to happen is to report back to the application that it has finished and then
> notify the user that it has finished.
>
> thanks for the help
> john
>
> "Kaoru Kodaka" <kaok@venus.dti.ne.jp> wrote in message
> news:20050609095229.5C90.KAOK@venus.dti.ne.jp...[color=green]
>> Dear John,
>>
>> I'm sorry, I didn't know the Start method doesn't extract
>> environment variables.
>>
>> You can use below code instead of it.
>>
>> p.Start("cmd.exe c:\ofac\ftpUpload.cmd")
>>
>> If target OS is Windows 9x, You have to use "command.com"
>> instead of "cmd.exe".
>>
>> I hope this will help you.
>>
>>
>>
>> On Wed, 8 Jun 2005 14:33:13 -0500
>> "John Wildes" <jwildes@gmail.com> wrote:
>>[color=darkred]
>>> I'm sorry but that's not correct either, if I use that, i get a SYSTEM
>>> CANNOT FIND FILE exception.
>>>
>>> Any more ideas.
>>>
>>> thanks for the help
>>> john
>>>
>>> "Kaoru Kodaka" <kaok@venus.dti.ne.jp> wrote in message
>>> news:20050608094429.8C41.KAOK@venus.dti.ne.jp...
>>> > Dear Crouchie1998,
>>> >
>>> > On Tue, 7 Jun 2005 20:40:17 +0100
>>> > "Crouchie1998" <crouchie1998@spamcop.net> wrote:
>>> >
>>> >> The 'cmd' file isn't a process.
>>> >>
>>> >> Processes are usually 'exe' files.
>>> >
>>> > This means He/She should use below.
>>> >
>>> > p.Start("%COMSPEC% c:\ofac\ftpUpload.cmd")
>>> >
>>> > ---
>>> > MVP kaok = MVP.ChangeMvpCategory("for C# 2004-2005.");
>>> > kaok.Web = "http://www.antoine.st/";
>>> >
>>>[/color]
>>
>>
>> ---
>> MVP kaok = MVP.ChangeMvpCategory("for C# 2004-2005.");
>> kaok.Web = "http://www.antoine.st/";
>> [/color]
>
>[/color]
Closed Thread