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.UseShellExecute = 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
amateur_playerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wguerramCommented:
Is your program a console window?

or you run the cmd.exe to do something?
0
amateur_playerAuthor Commented:
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()
0
amateur_playerAuthor Commented:
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
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

wguerramCommented:
Have you try the SHELL function instead?
0
amateur_playerAuthor Commented:
can you provide me an example how i can call the shell
Thanks
0
amateur_playerAuthor Commented:
my main concern is when i have   proc.StartInfo.UseShellExecute = 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.UseShellExecute = False)  does not work on the other machine and i have to manually click end now on that machine
Thanks
0
wguerramCommented:
Sorry, i don't think the shell function be of much help in this case.

It's a weird case.

Do you have the same OS version?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amateur_playerAuthor Commented:
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
0
amateur_playerAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.