Listing of VB Script (Enums)

Advertisement

msdev7807
Joined:
Posts:
31
Location:
MyTown

Listing of VB Script (Enums)

I have setup my VBScript per the article here (converted it to a .wsf file):
https://winscp.net/eng/docs/library_com_wsh#enums

Is there anyway to get a listing of all the enums?, i.e.
Session Property         Property Enum Setting                  Value 

Protocol                  Protocol_Sftp                           0   
With using
Set session = WScript.CreateObject("WinSCP.Session", "session_")
It seems like you should be able to enumerate through the enums via a loop and pull the above property enum settings out.
Martin, the guru, has been awesome in answering these type enum questions, but I want to be more self sufficient.

Thanks!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Listing of VB Script (Enums)

Why do you need that?
What do you want to list? Set of enum members is documented for each enum type on this site.
Or are you interested in the numerical values? Well, just print the enum values in a test script.
Of actually, way easier is to check WinSCP .NET assembly source code.
E.g. for Protocol enum, you will see this in dotnet/SessionOptions.cs:
public enum Protocol
{
    Sftp = 0,
    Scp = 1,
    Ftp = 2,
    Webdav = 3,
    S3 = 4,
}

Reply with quote

msdev7807
Joined:
Posts:
31
Location:
MyTown

.Net Assembly Source Code / .cs files.

Good Morning Martin,

Thank you again for your help. Can you point me to the WINSCP .NET Assembly Source Code (download link) (that contains all of the .cs files? Or does it install the .cs files when you install the .NET Assembly / COM Library? I just need the all of the .cs files so I can have all the values of the enumerations defined. As per your example you posted, but for everything.

Again, I appreciate your help!

Reply with quote

msdev7807
Joined:
Posts:
31
Location:
MyTown

.Net Assembly Source Code / .cs files.

Thanks Martin,

That takes care of the enum values. But I am still having issues with just WinSCP syntax for VB Scripting.

I want to set file permissions for the Put Files method and constructing the syntax seems to still be challenging.
I end up doing a lot of trial and error. I need to set the file permissions to 0777 octal. I have tried these combinations.
transferOptions.FilePermissions.Octal( "0777")
transferOptions.FilePermissions.Octal = "0777"
transferOptions.FilePermissions.FilePermissions.Octal( "0777")
transferOptions.FilePermissions.FilePermissions.Octal = "0777"
transferOptions.FilePermissions_FilePermissions.Octal( "0777")
transferOptions.FilePermissions_FilePermissions.Octal = "0777"
VBScript runtime error: Object required: '[object]'
In the TransferOptions.cs file here is the definition of FilePermissions:
public sealed class TransferOptions
{
    public bool PreserveTimestamp { get; set; }
    public FilePermissions FilePermissions { get; set; }
    ...
}
When you provide the syntax, please let me know what steps you took to determine the syntax. With VB Scripting, you don't have any IntelliSense to help construct proper syntax. Even if you find out via IntelliSense in VB.NET it may not translate directly to VB script. That is what prompted my first question with Enums. Hindsight I would have probably taken a closer look at PowerShell. But most of the file transfers we do can be done with the basic VB Script example. Just run across these one-offs that require setting file permissions, for example

Again Martin, thanks so much for your help.

Reply with quote

Advertisement

msdev7807
Joined:
Posts:
31
Location:
MyTown

Enum List

Hi Martin,

I think I figured it out. It looks like FilePermissions is actually an object that has to be instantiated. I am going to work with it and I'll let you know.

Thanks in advance!

Update: Everything worked fine! Thanks again Martin!

Reply with quote

Advertisement

You can post new topics in this forum