Autmation Windows Script Host Object Model.FileSystemObject

tburgertburger Member Posts: 6
I am trying to automate the code at the bottom of this message and I keep getting the errror bellow. I have made sure that the NAS user login has full permissions to the folders. The code does work from UI. Any help is apriciated.

Error: This message is for C/AL programmers: The call to member GetFolder failed. Unknown Class returned the following message: Unknown Error

Code:

IF ISCLEAR(FSO) THEN
CREATE(FSO);

Folder:=FSO.GetFolder('\\server\d$\lexicom\inbox\commercehub');
Files:=Folder.Files;

IF Files.Count>0 THEN BEGIN
FSO.CopyFile('\\svr2k1\d$\lexicom\inbox\commercehub\*', 'c:\navision\edi\combo');
FSO.MoveFile('\\svr2k1\d$\lexicom\inbox\commercehub\*', '\\server\d$\lexicom\inbox\commercehub\archive\');
END;

//Import Files
Import850;

Folder:=FSO.GetFolder('c:\navision\edi\c\outbox');
Files:=Folder.Files;
IF Files.Count>0 THEN BEGIN
FSO.CopyFile('c:\navision\edi\c\outbox\*','c:\navision\edi\c\outbox\archive\');
FSO.MoveFile('c:\navision\edi\c\outbox\*','\\server\d$\lexicom\outbox\commercehub\');
END;

Folder:=FSO.GetFolder('c:\navision\edi\kohls\outbox');
Files:=Folder.Files;
IF Files.Count>0 THEN BEGIN
FSO.CopyFile('c:\navision\edi\k\outbox\*','c:\navision\edi\k\outbox\archive\');
FSO.MoveFile('c:\navision\edi\k\outbox\*','\\server\d$\lexicom\outbox\commercehub\');
END;


CLEAR(FSO);

Comments

  • ayhan06ayhan06 Member Posts: 210
    tburger wrote:
    I am trying to automate the code at the bottom of this message and I keep getting the errror bellow. I have made sure that the NAS user login has full permissions to the folders. The code does work from UI. Any help is apriciated.

    Error: This message is for C/AL programmers: The call to member GetFolder failed. Unknown Class returned the following message: Unknown Error

    Code:

    IF ISCLEAR(FSO) THEN
    CREATE(FSO);

    Folder:=FSO.GetFolder('\\server\d$\lexicom\inbox\commercehub');
    Files:=Folder.Files;

    IF Files.Count>0 THEN BEGIN
    FSO.CopyFile('\\svr2k1\d$\lexicom\inbox\commercehub\*', 'c:\navision\edi\combo');
    FSO.MoveFile('\\svr2k1\d$\lexicom\inbox\commercehub\*', '\\server\d$\lexicom\inbox\commercehub\archive\');
    END;

    //Import Files
    Import850;

    Folder:=FSO.GetFolder('c:\navision\edi\c\outbox');
    Files:=Folder.Files;
    IF Files.Count>0 THEN BEGIN
    FSO.CopyFile('c:\navision\edi\c\outbox\*','c:\navision\edi\c\outbox\archive\');
    FSO.MoveFile('c:\navision\edi\c\outbox\*','\\server\d$\lexicom\outbox\commercehub\');
    END;

    Folder:=FSO.GetFolder('c:\navision\edi\kohls\outbox');
    Files:=Folder.Files;
    IF Files.Count>0 THEN BEGIN
    FSO.CopyFile('c:\navision\edi\k\outbox\*','c:\navision\edi\k\outbox\archive\');
    FSO.MoveFile('c:\navision\edi\k\outbox\*','\\server\d$\lexicom\outbox\commercehub\');
    END;


    CLEAR(FSO);


    make sure that windows login for application server has permission for this operation. type services.msc in windows' run dialog and check user for navision application server service. permission is not related to nav user.
  • garakgarak Member Posts: 3,263
    check the permission of the NAS Windows User and / or check it also with the NAS user and a NAV client on the NAS server.
    Do you make it right, it works too!
  • tburgertburger Member Posts: 6
    I commented out everything but the code below and made the NAS User admin on that box for this test.

    Folder:=FSO.GetFolder('c:\navision\edi\kohls\outbox');
    Files:=Folder.Files;
    IF Files.Count>0 THEN BEGIN
    FSO.CopyFile('c:\navision\edi\k\outbox\*','c:\navision\edi\k\outbox\archive\');
    FSO.MoveFile('c:\navision\edi\k\outbox\*','\\server\d$\lexicom\outbox\commercehub\');
    END;

    Error: An exception was raised in method GetFolder. The OLE control or Automation server has returned error (HRESULT) -2147352567.
    The component did not provide the exception description.
  • tburgertburger Member Posts: 6
    does anyone have any new ideas or a differant way to do this with automation? If I can't do it in NAV, I can create a windows service to move the docs for me but I would like it if it were all part of the same process.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Can't you use the virtual table "File" in NAV to traverse through the files in a given directory, and then use FILE.COPY to copy them?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • gerdhuebnergerdhuebner Member Posts: 155
    Have you tried this?
    Folder:=FSO.GetFolder('c:\\navision\\edi\\kohls\\outbox');
    
  • tburgertburger Member Posts: 6
    We found the issue. It is a windows 2000 server security issue. Once we moved the process to a newer server, it works fine.
  • mgmmgm Member Posts: 126
    Probably a bit late, but I just ran into this topic.

    When moving files, you can also use the build in standard NAV RENAME function:

    [Ok :=] File.RENAME(OldName, NewName)
Sign In or Register to comment.