Running FTP command from a batch file
Posted on 2010-08-19
I did try to call a Batch file from VB.Net using the shell command. This works perfectly & the command from the VB.NET application is as follows:
The getslicer1.bat file is this :
This is ok too.
The ftp file which is invoked by the above bat file is :
rename statex.txt statex_slicer1.txt
Which works too most of the time. When I say most of the time I mean that sometimes when the batch file is called the location where the .ftp file is searched by the .bat file is changing!!!!
So The shell command calls the getslicer1.bat file from C:\daemons and the getslicer1.ftp file is located in the C:\ directory so it's executed however sometimes if I pause the batch file I can see that the batch command in the command line is looking to a different directory !!!
I can't understand why as nobody and nothing changed anything in NEITHER the FTP or BAT code but yet when it executes it tries to look for the ftp file in a different location.
I think that I should force the batch file to search for the fpt in a certain location.
When I did first run the getslicer1.bat file using the shell command it looked by default in C:\ so I assumed that this is the default.
However if I click on the bat file inside the :C\daemons where it is located it will show an error (if I pause the code) as it looks for the ftp inside the C:\daemons.
So obviously the location where the batch file will look for the FTP file depends on the method it is invoked.
If invoked by shell from VB.NET looks for the ftp in the C:\ but if run locally it looks for the file in the same directory where it was initiated from.However if called by the SHELL command the location where the bat file tries to run the ftp file is chnaging based on god knows what.
Could you please help me with this?