Using WshShell to retrieve files via ftp - Where is my files?

Hi Guys,

I’m trying to make Navision fetch some files via ftp, for importing and handling through NAS.

I’ve created a BAT-file that can do that for me.
First it connects to the ftp-site, and fetches the files.
Then it copies the files to some other location. (right now it copies files between 2 locations locally on my PC).

When I run the BAT-file directly in an explorer, everything works perfectly.
But when I try to run the BAT-file from within Navision, the chain breaks somewhere.

I use WshShell.RUN(Textvar,Par1,Par2).
I’ve tried to change Par1 (WindowsStyle) to 1, for the window to open, so that I can see what is going on.
And I can see that the files are retrieved ok.
But when it comes to copying them to the other location, it says file not found. [:’(]

So my question is…
Why does this work when run from the explorer, but not when run from inside Navision?
When I run it from the explorer, the files are initially stored in the folder that contains the BAT-file.
But when run from inside Navision, they seems to be stored somewhere else…
Searching for them haven’t given me any clue, so they are apparently not stored directly on my PC.

I expect that if I break my BAT-file up, into 2, and do the retrieval in the first, and then do the copying in the second, it will work…
But I haven’t tried it yet.

If I’m not wrong, files are stored in NAS folder. Normally NAS user is a user without any special permission so it can’t write to that folder.

Hi Nuno,

Well You just pointed out a potential error later on. Thx.
But it must be possible to solve by adding permissions to the user that we create to run the NAS.

Right now I test it from a normal NAV-client (4.0 SP3), so I would guess that the permissions from my user-account are applied?

When you execute ftp command have you defined full path to file with ftp commands? When you run In Navision is recommend to use full paths.

Yes, I have defined full file-paths all over.
(did do that mistake to begin with [:D])

But also the problem, apparently, is not in the ftp-commands, as I can see that they run ok, and i get a “file transfer complete” (or something like that) message in the command-window, when I run it with windows.

Then as the COPY-command is fired, I get a “File not found” message.
I don’t get that when I manually run the BAT-file from the explorer.

One more try, but still in ftp commands. (I promise it will last in this part [:)]) In FTP you can define local output folder with command LCD, have you defined it? Check LCD command help in

That did the trick. [<:o)]

Thanks a lot Nuno.

Though I still don’t understand where my files where…
From what I understand in the link You sent me, the default directory is “Where ftp are started”…
So when I run the BAT-file from the explorer, that is where the files are delivered…
But I would assume that if i run the BAT-file from within Navision, it will not change the location of the BAT-file that fires the ftp-command, and therefore would be the same.
Or it could be the NAV-programfolder, but I’ve searched the entire computer without finding the files???

Well, that’s a minor thing now, I can get on with my solution…
Thanks again VERY much.

When you searched for file did you included hidden folders? When you search for a file in Windows it can be in a hidden folder for example in Local Settings and you couldn’t find it. Just guessing …. [:P]