amateur_player
asked on
closing cmd.exe from vb.net automatically (urgent)
I executed a batch file that ftp's files from vb.net. If the files are not downloaded in 5 minutes i kill the download process and retry again. I implemented the following statements. I want the cmd.exe window to be closed automatically. On my machine this program works with cmd.exe not requiring any manual intervention but on the machine where this program was supposed to run i had to manually click on end now. Does any one has suggestion. Thanks
Try
proc.StartInfo.UseShellExe cute = False
Catch ex As Exception
End Try
Try
proc.CloseMainWindow()
Catch ex As Exception
End Try
Try
proc.Kill()
proc.Close()
Catch ex As Exception
End Try
Try
proc.StartInfo.UseShellExe
Catch ex As Exception
End Try
Try
proc.CloseMainWindow()
Catch ex As Exception
End Try
Try
proc.Kill()
proc.Close()
Catch ex As Exception
End Try
ASKER
I have a windows application that runs for every few hours and retrieves the files from remote site. i HAVE A batch file that runs a file FTP.txt. The FTP.txt has information of all the files to be downloaded along with ftp server user name, password, ftp directory name and name of the file to be downloaded. There are around 40000 files to be downloaded. The batch file is opened by VB.net by the following code. When the batch file is opened it opens a cmd.exe window and starts doing FTP. I download 40000 files, 100 at a time. If 100 are not downloaded in 10 minutes i.e. if cmd.exe does not quit in 10 minutes i forcibly close the cmd.exe and rerun it again. There have been issues with their ftp server because of which i could not implement wininet dll methods. so i had to use batch file to download the files.
proc = New Process
proc.StartInfo.FileName = BatchFileName
proc.Start()
proc = New Process
proc.StartInfo.FileName = BatchFileName
proc.Start()
ASKER
My concern is i could not quit the cmd.exe window. Because of this whenever new thread is started there are a number of cmd.exe windows on desktop. The code i wrote works on my machine but not on the machinbe where it was supposed to run
Thanks
Thanks
Have you try the SHELL function instead?
ASKER
can you provide me an example how i can call the shell
Thanks
Thanks
ASKER
my main concern is when i have proc.StartInfo.UseShellExe cute = False then the command prompt is closed on my machine. When it is set it to true a new window that says end now or cancel opens and when we click end now the window is closed. why the same statement ( proc.StartInfo.UseShellExe cute = False) does not work on the other machine and i have to manually click end now on that machine
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nope. The operating system on live machine was windows 2000 and on mine windows xp. Now i added one line proc.StartInfo = New ProcessStartInfo
and i am keeping a watch see if it works.
proc = New Process
proc.StartInfo = New ProcessStartInfo
proc.StartInfo.FileName = BatchFileName
and i am keeping a watch see if it works.
proc = New Process
proc.StartInfo = New ProcessStartInfo
proc.StartInfo.FileName = BatchFileName
ASKER
I found the answer. The above code works only on operating systems above windows 2000. If you use wininet.dll for ftp that also works on operating systemn above windows 2000
thanks
thanks
or you run the cmd.exe to do something?