Highlighted
Absent Member.
Absent Member.
1247 views

[archive] Windows Scripting Host

[Migrated content. Thread originally posted on 13 June 2005]

I try to do a kind of "c$listdir" with Activx.
So i have a wsh.def and these lines:

01 wsh-filesyst-handle handle of @FileSystemObject.
01 wsh-folder-handle handle of @Folder.
01 wsh-col-folder-handle handle of IFolderCollection.
01 wsh-col-file-handle handle of IFileCollection.
01 wsh-file-handle handle of @File.

01 file-anz pic 9(06).
01 file-z pic 9(06).

create @FileSystemObject of IWshRuntimeLibrary
handle in wsh-filesyst-handle.

modify wsh-filesyst-handle, @GetFolder(my-folder)
giving wsh-folder-handle.

inquire wsh-folder-handle, @Files()
wsh-col-file-handle.

** And now i try to access each file (maybe the index has to start with zero, but can't test it yet):

inquire wsh-col-file-handle, @count File-anz.

move 1 to file-z.
perform varying file-z from 1 by 1 until file-z >= file-anz
*P* inquire wsh-col-file-handle, @item(by name key file-z)
in wsh-file-handle

inquire wsh-file-handle, @name datei-name
destroy wsh-file-handle
end-perform.


At the line marked with *P* i get an error "invalid Parameter".
I tried allready to use the "c$setvariant" to translate file-z into a variant, but no changes. there are 8 files in the directory and the @count shows up the right count, so that can not be the problem.

The definition of the @item is:
PROPERTY-GET, 0, @Item,
"VARIANT" @Key, TYPE 12
RETURNING "IFile*", TYPE 9

I can't find the problem. Does anyone have an idea?
i need with program, because the "c$listdir" dont work for local files on thinclients.
0 Likes
7 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Windows Scripting Host

What type of client are you using (Windows version)?

Remember that Micro$oft have done a fair bit to stop ActiveX controls having access to the local hardware (including files) for security reasons (it was wide open before).

Perhaps you have to 'relax' some of these measures? However, that will leave you wide open to the kind of security issues that prompted the changes in the first place.

Good luck.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Windows Scripting Host

I tried it on Win2000 (Client) and WinXP.
And i tried the same "operation" in VB6 as ActiveX and it works properly.
So i don't think that it is a security problem or a activeX restriction.

I suggest the real problem is to do a "for each" loop in AcuCobol.
But i also think, that the described way is the only one to do this loop. Or am i wrong?

By the way: i try it with 6.2
And the WSH Version is 5.6
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Windows Scripting Host

Try using @Files instead of IFileCollection and @Folders instead of IFolderCollection.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Windows Scripting Host

Note that these objects make use of the collection NewEnum. This is a specia variant that is not a published object, just like it is with the Font class and the Picture class. These has been implemented specially in the runtime, and we have the NewEnum class on the drawing table as well. There is no way around it unfortunately, and I cannot for the time being give any promise for what version it will appear in.

A workaround is to use the Windows API FindFirstFile and FindNext API. If you have attended our Adv. Windows class, you should find an example of this in the solution directory of the day1 exercises on the CD. The program is named FindFile.cbl

The fully functional example works using C:\*.* as a search path, but may easily be changed to accomodate your needs.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Windows Scripting Host

What we have done when we need to access more complex active-x and windows API routines is to wrap them up in our own active-X vb control. All the processing can be done in VB passing the results back as string, integers etc. This works well in a thin-client environment as we just copy and register are VB dll.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Windows Scripting Host

What we have done when we need to access more complex active-x and windows API routines is to wrap them up in our own active-X vb control. All the processing can be done in VB passing the results back as string, integers etc. This works well in a thin-client environment as we just copy and register are VB dll.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Windows Scripting Host

sorry, have been busy the last days.

@DanM
I tried it and the error still occurs.

@gforseth
i hate it, when you say things like this ("There is no way around it unfortunately") 😉 .
And i hate it, when you seems to be absolutely right 😉 .

@Richard
i had already the same idea, but the registering is a ugly process so i pushed these thoughts aside. Now it seems to be the only way. I think i will try the "own control" way in the next days.

Thanks to all of you for your help and ideas.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.