Autmation Windows Script Host Object Model.FileSystemObject
tburger
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);
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);
0
Comments
-
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.0 -
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!0
-
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.0 -
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.0
-
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)0
-
Have you tried this?
Folder:=FSO.GetFolder('c:\\navision\\edi\\kohls\\outbox');New kits on the blog: https://massivedynamicsblog.wordpress.com0 -
We found the issue. It is a windows 2000 server security issue. Once we moved the process to a newer server, it works fine.0
-
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)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

