Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

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
0
amateur_player
Asked:
amateur_player
  • 6
  • 3
1 Solution
 
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now