© 2010 ActiveXperts Software B.V. contact@activexperts.com
PART I: Getting Started
PART II: Objects
PART III: Support, Licensing
Adding network communications capabilities to an application is not a simple matter.
It requires specialized knowledge that might be outside an individual programmer's expertise.
For years, VBScript, Visual Basic and Visual C++ developers have relied upon the power, flexibility and reliability of the
ActiveSocket Network Communication Toolkit from ActiveXperts Software. And today, also .NET developers use this control.
With ActiveSocket you can communicate across IP networks, including the Internet. ActiveSocket provides an easy-to-use scripting interface for IP communications. By using ActiveSocket, you can very easily create or enhance applications with network features.
Use ActiveSocket to integrate the following IP protocols in your application or script:
ActiveSocket can be used by any of the following operating systems:
ActiveSocket Toolkit can be used by any of the following development languages:
The core of ActiveSocket Toolkit is an ActiveX/COM component that comes in a 32-bit and a 64-bit version:
ActiveSocket can be distributed easily to any server and workstation in your network 9required a Processional License, see also Click here for more information about the installation.
ActiveSocket Toolkit can be used by any of the following operating systems:
NOTE: On 64 bits systems, you can run 32- and 64 bit programs. To integrate ActiveSocket in a 64-bit (web) application of service, use the 64-bit ASocketx64.dll. To integrate ActiveSocket in a 32-bit (web) application of service, use the 32-bit ASocket.dll.
The ActiveSocket Toolkit can be used by any of the following programming languages:
The ActiveSocket Toolkit package consists of 3 components; any combination of components can be installed:
Simply run the ASOCKET.EXE Setup program. The InstallShield wizard will guide you through the rest of the setup.
If you choose the ActiveSocket Toolkit COM component, the Setup program can
perform the registration of the COM component for you. But it will also
give you the opportunity to register the object yourself.
Any subsequent installation of ActiveSocket Toolkit can be performed either manually or by using the Setup program.
Any subsequent installations can be performed using the setup program.
But since the installation of the core components is very simple, you
may want to do it manually, or integrate it into your companies
software distribution program.
If you choose to install the COM component manually on other machines, simply perform the following actions:
The following code snippets (VBScript) illustrate how to use various ActiveSocket objects.
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create object Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Host = "ns1.interstroom.nl" ' DNS server objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Show all DNS records for activexperts.com WScript.Echo "Lookup, result: " & objDnsServer.LastError If( objDnsServer.LastError <> 0 ) Then WScript.Quit End If If ( objDnsServer.IsAuthoritative = True ) Then WScript.Echo "Server is an authority for this domain" Else WScript.Echo "Server is not an authority for this domain" End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Iterate over all DNS records; get first record While ( objDnsServer.LastError = 0 ) Select Case objDnsRecord.Type Case objConstants.asDNS_TYPE_A WScript.Echo "Type : A" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "IPv4 Address : " & objDnsRecord.Address Case objConstants.asDNS_TYPE_AAAA WScript.Echo "Type : AAAA" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "IPv6 Address : " & objDnsRecord.Address Case objConstants.asDNS_TYPE_CNAME WScript.Echo "Type : CNAME" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Alias : " & objDnsRecord.Address Case objConstants.asDNS_TYPE_MX WScript.Echo "Type : MX" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Preference : " & objDnsRecord.Preference WScript.Echo "Mail Exchange : " & objDnsRecord.MailExchange Case objConstants.asDNS_TYPE_NS WScript.Echo "Type : NS" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Name Server : " & objDnsRecord.NameServer Case objConstants.asDNS_TYPE_PTR WScript.Echo "Type : PTR" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Host : " & objDnsRecord.Address Case objConstants.asDNS_TYPE_SOA WScript.Echo "Type : SOA" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Name Server : " & objDnsRecord.NameServer WScript.Echo "MailBox : " & objDnsRecord.MailBox WScript.Echo "Serial : " & objDnsRecord.SerialNumber WScript.Echo "Refresh : " & objDnsRecord.RefreshInterval WScript.Echo "Retry Interval : " & objDnsRecord.RetryInterval WScript.Echo "Expiration Limit : " & objDnsRecord.ExpirationLimit WScript.Echo "Minimum TTL : " & objDnsRecord.MinimumTTL End Select WScript.Echo "TTL : " & objDnsRecord.TTL WScript.Echo Set objDnsRecord = objDnsServer.GetNextRecord ' Iterate over all DNS records; get next record Wend
Set objFtpServer = CreateObject ( "ActiveXperts.FtpServer" ) objFtpServer.Connect "ftp.activexperts-labs.com","anonymous","" ' Connect to the FTP server Wscript.Echo "Connect, result: " & objFtpServer.LastError If( objFtpServer.LastError <> 0 ) Then ' If connect failed then quit WScript.Quit End If objFtpServer.ChangeDir "samples/ASocket/Visual Basic/Telnet" ' Change directory Wscript.Echo "ChangeDir, result: " & objFtpServer.LastError If( objFtpServer.LastError <> 0 ) Then ' If ChangeDir fails then disconnect and quit objFtpServer.Disconnect WScript.Quit End If Set objFtpFile = objFtpServer.FindFirstFile() ' Iterate over all files; start with the first one While( objFtpServer.LastError = 0 ) WScript.Echo "Name: " & objFtpFile.Name ' Display file name WScript.Echo "IsDirectory: " & objFtpFile.IsDirectory ' Display directory or file WScript.Echo "Size: " & objFtpFile.Size ' Display file size WScript.Echo "Date: " & objFtpFile.Date ' Display file date ' To save the file, call the GetFile function. ' strSaveAs = "C:\temp\" & objFtpFile.Name ' objFtpServer.GetFile objFtpFile.Name, strSaveAs ' Wscript.Echo "Save file, result: " & objFtpServer.LastError ' To delete a file, call the DeleteFile function. ' objFtpServer.DeleteFile objFtpFile.Name ' Wscript.Echo "Delete, result: " & objFtpServer.LastError Set objFtpFile = objFtpServer.FindNextFile() ' Next file Wend objFtpServer.Disconnect ' Disconnect
Set objHttp = CreateObject( "ActiveXperts.Http" ) ' Create new Http instance objHttp.ProxyServer = "proxy01.intranet.dom" ' Proxy server - if required objHttp.ProxyAccount = "mjackson" ' Proxy authentication objHttp.ProxyPassword = "mjackson1" ' Proxy authentication objHttp.Connect( "www.activexperts.com/products" ) ' Connect to a web server WScript.Echo "Connect, result: " & objHttp.LastError If( objHttp.LastError <> 0 ) Then WScript.Quit End If strData = objHttp.ReadData ' Read web page data WScript.Echo "ReadData, result: " & objHttp.LastError If( objHttp.LastError <> 0 ) Then WScript.Echo strData ' Display web page data End If objHttp.Disconnect
Set objIcmp = CreateObject("ActiveXperts.Icmp") ' Create new Icmp instance
For i = 1 To 4 ' Prepare for 4 consecutive pings
objIcmp.Ping "www.activexperts.com", 2000 ' Ping host (time-out: 2000 msecs)
If( objIcmp.LastError = 0 ) Then
WScript.Echo "Reply from " & strHost & _ ' Display Ping results
": time=" & objIcmp.LastDuration & "ms" & _ ' Display Duration
" TTL=" & objIcmp.LastTtl ' Display TTL
Else
WScript.Echo "Error " & objIcmp.LastError
End If
Next
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create a new IPtoCountry instance objIPC.Host = "www.activexperts.com" ' Host name (or IP address) that you want to resolve objIPC.Query() ' Host name (or IP address) that you want to resolve WScript.Echo "Query, result: " & objIPC.LastError ' Result of Query; 0 means: success If objIPC.LastError = 0 Then WScript.Echo "Host " & strHost & " is located in " & objIPC.CountryName End If
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.Server = "messenger2.hotmail.com" ' Use messenger2.hotmail.com objMsn.MsnAccount = "mymeself@activexperts.com" ' Set MSN Account objMsn.MsnPassword = "topsecret" ' Set MSN Password objMsn.Message = "Hello World !!!!" ' Set MSN Message objMsn.AddRecipient "mycollegue1@activexperts.com" ' Add recipient(s) objMsn.AddRecipient "mycollegue2@activexperts.com" objMsn.Send ' Send the message WScript.Echo "Result : " & objMsn.LastError ' Display the result
Set objNtp = CreateObject("ActiveXperts.Ntp") ' Create new Ntp instance
objNtp.GetTime "fartein.ifi.uio.no" ' Query the time server
If( objNtp.LastError <> 0 ) Then
WScript.Echo "Unable to retrieve time, error: " & objNtp.LastError
WScript.Quit
End If
WScript.Echo "Time on timeserver: " & objNtp.Year & _ ' Display date and time
"/" & objNtp.Month & "/" & objNtp.Day & _ ' Display date and time
" " & objNtp.Hour & ":" & objNtp.Minute & _ ' Display date and time
":" & objNtp.Second
WScript.Echo "DifferenceTime Server / Local PC: " & _ ' Display time offset
objNtp.LocalOffsetSeconds & " seconds" ' Display time offset
End If
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new Snmp instance objSnmpManager.Initialize ' Initialize Snmp objSnmpManager.Open "192.168.1.100", "public" If( objSnmpManager.LastError = 0 ) Set objSnmpObject = objSnmpManager.Get( "system.sysName.0" ) ' Get SnmpObject object While( objSnmpManager.LastError = 0 ) WScript.Echo "Type: " & objSnmpObject.Type WScript.Echo "Value: " & objSnmpObject.Value Set objSnmpObject = objSnmpManager.GetNext() ' Get next SnmpObject object End If objSnmpManager.Close End If objSnmpManager.Shutdown ' Uninitialize Snmp
' T R A P R E C E I V E R . V B S Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance objTrapManager.Initialize ' Initialize SNMP If( objTrapManager.LastError <> 0 ) Then WScript.Quit End If objTrapManager.StartListening "public" ' Start listening now If( objTrapManager.LastError <> 0 ) Then objTrapManager.Shutdown ' Uninitialize SNMP WScript.Quit End If Set objSnmpTrap = objTrapManager.GetFirstTrap ' Get trap While( objTrapManager.LastError = 0 ) WScript.Echo "Trap from : " & objSnmpTrap.Host WScript.Echo " Community : " & objSnmpTrap.Community Set objSnmpObject = objSnmpTrap.GetFirstObject While( objSnmpTrap.LastError = 0 ) ' iterate over all variables in the trap WScript.Echo "OID : " & objSnmpObject.OID WScript.Echo "Value:" & objSnmpObject.Value WScript.Echo "Type:" & GetTypeString( objSnmpObject.Type ) Set objSnmpObject = objSnmpTrap.GetNextObject WEnd Set objSnmpTrap = objTrapManager.GetNextTrap ' Get next trap WEnd objTrapManager.StopListening ' Stop listening for incoming traps objTrapManager.Shutdown ' Uninitialize SNMP ' T R A P S E N D E R . V B S Set objSnmpTrapManager = CreateObject("ActiveXperts.SnmpTrapManager") ' Create a new SnmpTrapManager instance Set objSnmpTrap = CreateObject( "ActiveXperts.SnmpTrap" ) ' Create a new SnmpTrap instance Set objSnmpObject = CreateObject( "ActiveXperts.SnmpObject" ) ' Create a new SnmpObject instance Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create a new Constants instance objSnmpTrapManager.Initialize ' Initialize SNMP If( objSnmpTrapManager.LastError <> 0 ) Then WScript.Quit End If ' Set trap properties objSnmpTrap.Clear() objSnmpTrap.Host = "server06" objSnmpTrap.Community = "public" ' Add a variable to the trap objSnmpObject.Clear() ' Clear trap object objSnmpObject.OID = ".1.3.6.1.2.1.1.5.0" ' Set trap properties objSnmpObject.Type = objConstants.asSNMP_TYPE_IPADDRESS ' Set trap properties objSnmpObject.Value = "10.0.0.1" ' Set trap properties objSnmpTrap.AddObject objSnmpObject ' Add the trap to the queue ' Add another variable to the trap objSnmpObject.Clear() ' Clear trap object objSnmpObject.OID = ".1.3.6.1.2.1.1.5.1" ' Set trap properties objSnmpObject.Type = objConstants.asSNMP_TYPE_OCTETSTRING ' Set trap properties objSnmpObject.Value = "One two three" ' Set trap properties objSnmpTrap.AddObject objSnmpObject ' Add the trap to the queue objSnmpTrapManager.Send objSnmpTrap ' Send trap WScript.Echo "Send, result: " & objSnmpTrapManager.LastError ' Display the result objSnmpTrapManager.Shutdown ' Uninitialize SNMP
Set objSsh = CreateObject("ActiveXperts.Ssh") ' Create an Ssh instance
objSsh.Host = "192.168.1.10" ' Hostname or IP address of remote UNIX/LINUX machine
objSsh.UserName = "root" ' Login as 'root'
objSsh.Password = "topsecret" ' Use a password to login
objSsh.Command = "/bin/ls" ' Command to execute
objSsh.ScriptTimeOut = 5000 ' Time-out (in milliseconds)
objSsh.Run ' Execute the command now
WScript.Echo "Run: result = " & objSsh.LastError
If objSsh.LastError <> 0 Then
WScript.Quit
End If
' YES, command has completed
WScript.Echo "StdErr: " & objSsh.StdErr ' Print Standard Output
WScript.Echo "StdOut: " & objSsh.StdOut ' Print Standard Error
WScript.Echo "Ready."
' S E R V E R . V B S
Set objTcp = CreateObject("ActiveXperts.Tcp") ' Create new Tcp instance
Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create a new Constants instance
objTcp.Protocol= objConstants.asSOCKET_PROTOCOL_RAW ' Plain TCP/IP communications
objTcp.StartListening 1500 ' Listen on port 1500
If objTcp.LastError <> 0 Then
WScript.Echo "Error " & objTcp.LastError & ": " & objTcp.GetErrorDescription( objTcp.LastError )
WScript.Quit
End If
Do while objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_LISTENING
objTcp.Sleep 1000 ' Wait for incoming connection...
Loop
If objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_LISTENING Then
str = "" ' Connection established
Do While objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_LISTENING and str <> "Quit"
If objTcp.HasData Then
str = objTcp.ReceiveString
WScript.Echo "ReceiveString: " & str
End If
objTcp.Sleep 100
Loop
objTcp.Disconnect ' And finally, disconnect
End If
' C L I E N T . V B S Set objTcp = CreateObject("ActiveXperts.Tcp") ' Create new Tcp instance Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create a new Constants instance objTcp.Protocol= objConstants.asSOCKET_PROTOCOL_RAW ' Plain TCP/IP communications objTcp.Connect "127.0.0.1", 1500 ' Connect to port 1500 on remote server WScript.Echo "Connect: result = " & objTcp.LastError If objTcp.LastError <> 0 Then WScript.Echo "Error #" & objTcp.LastError & ": " & objTcp.GetErrorDescription( objTcp.LastError ) WScript.Quit End If objTcp.SendString "This is a message" ' Send ASCII data WScript.Echo "SendString, result: " & objTcp.LastError objTcp.Sleep 1000 ' Hold script for 1000 msec objTcp.SendString "Quit", False ' Send ASCII data objTcp.Disconnect ' And finally, disconnect
Set objTcp = CreateObject("ActiveXperts.Tcp") ' Create new Tcp instance
Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create a new Constants instance
objTcp.Protocol = objConstants.asSOCKET_PROTOCOL_TELNET ' Telnet communications
objTcp.Connect "www.activexperts.com", 80 ' Connect to web site on port 80
Wscript.Echo "Connect,, result: " & objTcp.LastError
If objTcp.LastError <> 0 Then
WScript.Quit
End If
If objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED Then
strReceived = "" ' Connection established
objTcp.Sleep 1000
objTcp.SendString "GET /activsocket/demopage/ HTTP/1.1" ' Send string
objTcp.SendString "Host: www.activexperts.com" & vbCrlf ' Send string
objTcp.Sleep 1000
If objTcp.HasData Then
strReceived = objTcp.ReceiveString ' Receive data
WScript.Echo "RECV: " & strReceived
End If
objTcp.Sleep 1000
objTcp.Disconnect ' Disconnect from server
End If
Set objTftpServer = CreateObject ( "ActiveXperts.TftpServer" ) objTftp.Get "10.1.1.10", "/folder1/file.txt", "c:\\file.txt" ' Download file, save it locally Wscript.Echo "Get, result: " & objTftp.LastError If( objTftp.LastError <> 0 ) Then ' If download failed then quit WScript.Quit End If WScript.Echo "Packets received: " & objTftp.PacketsReceived ' Print download statistics WScript.Echo "Bytes received: " & objTftp.BytesReceived ' Print download statistics
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create new Rsh instance
objRsh.Clear
objRsh.Host = "192.168.1.10" ' Host/IP of the remote UNIX/LINUX machine
objRsh.Command = "/bin/ls" ' Command to execute on the remote machine
objRsh.ScriptTimeOut = 5000 ' Time-out (in milliseconds)
objRsh.Run ' Run the command now
If objRsh.LastError <> 0 Then
WScript.Echo "Error " & objRsh.LastError
WScript.Quit
End If
' YES, command has completed
WScript.Echo "StdErr: " & objRsh.StdErr ' Display stdout
WScript.Echo "StdOut: " & objRsh.StdOut ' Display stderr
' C L I E N T . V B S ' Create a socket instance Set objUdp = CreateObject ( "ActiveXperts.Udp" ) Set objConstants = CreateObject ( "ActiveXperts.ASConstants" ) ' Write some information to console WScript.Echo "ActiveSocket " & objUdp.Version & " demo." WScript.Echo "Expiration date: " & objUdp.ExpirationDate & vbCrLf ' Open socket to send to port 1500 on remote server objUdp.Open "localhost", 1500, False WScript.Echo "Open, result: " & objUdp.LastError & _ " (" & objUdp.GetErrorDescription( objUdp.LastError ) & ")" If( objUdp.LastError <> 0 ) Then WScript.Echo "Ready." WScript.Quit End If str = "This is just a message" objUdp.SendString str ' Send message WScript.Echo "SendString '" & str & "': result = " & objUdp.LastError objUdp.Sleep 100 str = "And this is another message" objUdp.SendString str ' Send another message WScript.Echo "SendString '" & str & "': result = " & objUdp.LastError objUdp.Sleep 100 str = "Quit" objUdp.SendString str ' Send last message WScript.Echo "SendString '" & str & "': result = " & objUdp.LastError objUdp.Sleep 100 objUdp.Close ' And finally, close the socket ' S E R V E R . V B S ' Create a socket instance Set objUdp = CreateObject ( "ActiveXperts.Udp" ) Set objConstants = CreateObject ( "ActiveXperts.ASConstants" ) ' Write some information to console WScript.Echo "ActiveSocket " & objUdp.Version & " demo." WScript.Echo "Expiration date: " & objUdp.ExpirationDate & vbCrLf ' Open socket to receive UDP datagrams on port 1500 on this machine objUdp.Open "localhost", 1500, True WScript.Echo "Open, result: " & objUdp.LastError & _ " (" & objUdp.GetErrorDescription( objUdp.LastError ) & ")" If( objUdp.LastError <> 0 ) Then WScript.Echo "Ready." WScript.Quit End If Do While str <> "Quit" str = objUdp.ReceiveString ' Receive message If( objUdp.LastError = 0 And str <> "" ) Then WScript.Echo "ReceiveString: " & str End If objUdp.Sleep ( 100 ) Loop objUdp.Close
Set objWOL = CreateObject( "ActiveXperts.WOL" ) ' Create a new WOL instance strMAC = "00-10-4B-BA-7A-51" objWOL.WakeUp strMAC ' Send magic packet to remote station identified by MAC WScript.Echo "WakeUp, result = " & objWOL.LastError ' Display the result
Make sure the ActiveSocket Toolkit is installed on your system. For details about installation, click here.
Add a reference to the object using the Visual Basic Solution Explorer:
You can use different ActiveSocket objects in one Visual Basic .NET application. The following code shows how to declare and create all ActiveSocket objects:
Imports ASocket Dim objConstants As SocketConstants ' Declaration objConstants = New SocketConstants() ' Creation Dim objDnsServer As DnsServer ' Declaration objDnsServer = New DnsServer() ' Creation Dim objDnsRecord As DnsRecord ' Declaration objDnsRecord = New DnsRecord() ' Creation Dim objFtpServer As FtpServer ' Declaration objFtpServer = New FtpServer() ' Creation Dim objFtpFile As FtpFile ' Declaration objFtpFile = New FtpFile() ' Creation Dim objHttp As Http ' Declaration objHttp = New Http() ' Creation Dim objIcmp As Icmp ' Declaration objIcmp = New Icmp() ' Creation Dim objIPC As IPtoCountry ' Declaration objIPC = New IPtoCountry() ' Creation Dim objMsn As Msn ' Declaration objMsn = New Msn() ' Creation Dim objNtp As Ntp ' Declaration objNtp = New Ntp() ' Creation Dim objRsh As Rsh ' Declaration objRsh = New Rsh() ' Creation Dim objScp As Scp ' Declaration objScp = New Scp() ' Creation Dim objSFtpServer As SFtpServer ' Declaration objSFtpServer = New SFtpServer() ' Creation Dim objSFtpFile As SFtpFile ' Declaration objSFtpFile = New SFtpFile() ' Creation Dim objSnmpTrapManager As SnmpTrapManager ' Declaration objSnmpTrapManager = New SnmpTrapManager() ' Creation Dim objSnmpTrap As SnmpTrap ' Declaration objSnmpTrap = New SnmpTrap() ' Creation Dim objSnmpMib As SnmpMibBrowser ' Declaration objSnmpMib = New SnmpMibBrowser() ' Creation Dim objSsh As Ssh ' Declaration objSsh = New Ssh() ' Creation Dim objTcp As Tcp ' Declaration objTcp = New Tcp() ' Creation Dim objTftpServer As TftpServer ' Declaration objTftpServer = New TftpServer() ' Creation Dim objUdp As Udp ' Declaration objUdp = New Udp() ' Creation Dim objWOL As WOL ' Declaration objWOL = New WOL() ' Creation
After these declarations and creation of the object(s), you can use the objects inside your Visual Basic .NET project.
Make sure the ActiveSocket Toolkit is installed on your system. For details about installation, click here.
Add a reference to the object using the Visual C# Solution Explorer:
You can use different ActiveSocket objects in one Visual C# .NET application. The following code shows how to declare and create the ActiveSocket objects:
using ASOCKETLib SocketConstants objConstants; // Declaration objConstants = new SocketConstants(); // Creation DnsServer objDnsServer; // Declaration objDnsServer = new DnsServer(); // Creation DnsRecord objDnsRecord; // Declaration objDnsRecord = new DnsRecord(); // Creation Http objHttp; // Declaration objHttp = new Http(); // Creation Icmp objIcmp; // Declaration objIcmp = new Icmp(); // Creation IPtoCountry objIPC; // Declaration objIPC = new IPtoCountry(); // Creation FtpServer objFtpServer; // Declaration objFtpServer = new FtpServer(); // Creation FtpFile objFtpFile; // Declaration objFtpFile = new FtpFile(); // Creation Msn objMsn; // Declaration objMsn = new Msn(); // Creation Ntp objNtp; // Declaration objNtp = new Ntp(); // Creation Rsh objRsh // Declaration objRsh = new Rsh(); // Creation Scp objScp // Declaration objScp = new Scp(); // Creation SFtpServer objSFtpServer; // Declaration objSFtpServer = new SFtpServer(); // Creation SFtpFile objSFtpFile; // Declaration objSFtpFile = new SFtpFile(); // Creation SnmpManager objSnmpManager; // Declaration objSnmpManager = new SnmpManager(); // Creation SnmpObject objSnmObject; // Declaration objSnmpObject = new SnmpObject(); // Creation SnmpTrapManager objSnmpTrapManager; // Declaration objSnmpTrapManager = new SnmpTrapManager(); // Creation SnmpTrap objSnmpTrap; // Declaration objSnmpTrap = new SnmpTrap(); // Creation SnmpMibBrowser objSnmpMib; // Declaration objSnmpMib = new SnmpMibBrowser(); // Creation Ssh objSsh // Declaration objSsh = new Ssh(); // Creation Tcp objTcp; // Declaration objTcp = new Tcp(); // Creation TftpServer objTftpServer; // Declaration objTftpServer = new TftpServer(); // Creation Udp objUdp; // Declaration objUdp = new Udp(); // Creation WOL objWOL; // Declaration objWOL = new WOL(); // Creation
After these declarations and creation of the object(s), you can use the objects inside your Visual C# .NET project.
ActiveSocket can be used in Visual Basic 5.x or higher. In Visual Basic, go to the 'Project/References...' menu item and check the box next to ActiveSocket Type Library. Now, you can declare and create ActiveSocket objects.
Create new ActiveSocket objects using the 'CreateObject' function:
Dim objConstants As ASOCKETLib.SocketConstants ' Declaration Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Creation Dim objDnsServer As ASOCKETLib.DnsServer ' Declaration Set objDnsServer = CreateObject( "ActiveXperts.DnsServer" ) ' Creation Dim objDnsRecord As ASOCKETLib.DnsRecord ' Declaration Set objDnsRecord = CreateObject( "ActiveXperts.DnsRecord") ' Creation Dim objIcmp As ASOCKETLib.Icmp ' Declaration Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Creation Dim objIPC As ASOCKETLib.IPtoCountry ' Declaration Set objIPC = CreateObject( "ActiveXperts.IPtoCountry") ' Creation Dim objFtpServer As ASOCKETLib.FtpServer ' Declaration Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Creation Dim objFtpFile As ASOCKETLib.FtpFile ' Declaration Set objFtpFile = CreateObject( "ActiveXperts.FtpFile") ' Creation Dim objHttp As ASOCKETLib.Http ' Declaration Set objHttp = CreateObject( "ActiveXperts.Http" ) ' Creation Dim objMsn As ASOCKETLib.Msn ' Declaration Set objMsn = CreateObject( "ActiveXperts.Msn") ' Creation Dim objNtp As ASOCKETLib.Ntp ' Declaration Set objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Creation Dim objRsh As ASOCKETLib.Rsh ' Declaration Set objRsh = CreateObject( "ActiveXperts.Rsh" ) ' Creation Dim objScp As ASOCKETLib.Scp ' Declaration Set objScp = CreateObject( "ActiveXperts.Scp" ) ' Creation Dim objSFtpServer As ASOCKETLib.SFtp ' Declaration Set objSFtpServer = CreateObject( "ActiveXperts.SFtp" ) ' Creation Dim objSFtpFile As ASOCKETLib.SFtpFile ' Declaration Set objSFtpFile = CreateObject( "ActiveXperts.SFtpFile") ' Creation Dim objSnmpManager As ASOCKETLib.SnmpManager ' Declaration Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Creation Dim objSnmpObject As ASOCKETLib.SnmpObject ' Declaration Set objSnmpObject = CreateObject( "ActiveXperts.SnmpObject") ' Creation Dim objSnmpTrapManager As ASOCKETLib.SnmpTrapManager ' Declaration Set objSnmpTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Creation Dim objSnmpTrap As ASOCKETLib.SnmpTrap ' Declaration Set objSnmpTrap = CreateObject( "ActiveXperts.SnmpTrap" ) ' Creation Dim objSnmpMib As ASOCKETLib.SnmpMibBrowser ' Declaration Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" ) ' Creation Dim objSsh As ASOCKETLib.Ssh ' Declaration Set objSsh = CreateObject( "ActiveXperts.Ssh" ) ' Creation Dim objTcp As ASOCKETLib.Tcp ' Declaration Set objTcp = CreateObject( "ActiveXperts.Tcp" ) ' Creation Dim objTftpServer As ASOCKETLib.TftpServer ' Declaration Set objTftpServer = CreateObject( "ActiveXperts.TftpServer" ) ' Creation Dim objUdp As ASOCKETLib.Udp ' Declaration Set objUdp = CreateObject( "ActiveXperts.Udp" ) ' Creation Dim objWOL As ASOCKETLib.WOL ' Declaration Set objWOL = CreateObject( "ActiveXperts.WOL") ' Creation
After these declarations and creation of the object(s), you can use the objects inside your Visual Basic 5.x/6.x project.
ActiveSocket can be used in Visual C++ projects. Include the *.h and *.c file provided by ActiveXperts to bind your code to the ActiveSocket component. These files are located in the Include directory of the Visual C++ samples directory. These are the files:
Declare and create new ActiveSocket objects like this:
ISocketConstants *pConstants;
CoCreateInstance(CLSID_SocketConstants, NULL, CLSCTX_INPROC_SERVER, IID_ISocketConstants, (void**) &pConstants );
IDnsServer *pDnsServer;
CoCreateInstance(CLSID_DnsServer, NULL, CLSCTX_INPROC_SERVER, IID_IDnsServer, (void**) &pDnsServer );
IDnsRecord *pDnsRecord;
CoCreateInstance(CLSID_DnsRecord, NULL, CLSCTX_INPROC_SERVER, IID_IDnsRecord, (void**) &pDnsRecord );
IFtpServer *pFtpServer;
CoCreateInstance(CLSID_FtpServer, NULL, CLSCTX_INPROC_SERVER, IID_IFtpServer, (void**) &pFtpServer );
IFtpFile *pFtpFile;
CoCreateInstance(CLSID_FtpFile, NULL, CLSCTX_INPROC_SERVER, IID_IFtpFile, (void**) &pFtpFile );
IHttp *pHttp;
CoCreateInstance(CLSID_Http, NULL, CLSCTX_INPROC_SERVER, IID_IHttp, (void**) &pHttp );
IIcmp *pIcmp;
CoCreateInstance(CLSID_Icmp, NULL, CLSCTX_INPROC_SERVER, IID_IIcmp, (void**) &pIcmp );
IIPtoCountry *pIPC;
CoCreateInstance(CLSID_IPtoCountry, NULL, CLSCTX_INPROC_SERVER, IID_IIPtoCountry, (void**) &pIPC );
IMsn *pMsn;
CoCreateInstance(CLSID_Msn, NULL, CLSCTX_INPROC_SERVER, IID_IMsn, (void**) &pMsn );
INtp *pNtp;
CoCreateInstance(CLSID_Ntp, NULL, CLSCTX_INPROC_SERVER, IID_INtp, (void**) &pNtp );
IRSh *pRsh;
CoCreateInstance(CLSID_RSh, NULL, CLSCTX_INPROC_SERVER, IID_IRSh, (void**) &pRSh );
IScp *pScp;
CoCreateInstance(CLSID_Scp, NULL, CLSCTX_INPROC_SERVER, IID_IScp, (void**) &pScp );
ISFtpServer *pSFtpServer;
CoCreateInstance(CLSID_SFtpServer, NULL, CLSCTX_INPROC_SERVER, IID_ISFtpServer, (void**) &pSFtpServer );
ISFtpFile *pSFtpFile;
CoCreateInstance(CLSID_SFtpFile, NULL, CLSCTX_INPROC_SERVER, IID_ISFtpFile, (void**) &pSFtpFile );
ISnmpManager *pSnmpManager;
CoCreateInstance(CLSID_SnmpManager, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpManager, (void**) &pSnmpManager );
ISnmpObject *pSnmpObject;
CoCreateInstance(CLSID_SnmpObject, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpObject, (void**) &pSnmpObject );
ISnmpTrapManager *pSnmpTrapManager;
CoCreateInstance(CLSID_SnmpTrapManager, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpTrapManager, (void**) &pSnmpTrapManager );
ISnmpTrap *pSnmpTrap;
CoCreateInstance(CLSID_SnmpTrap, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpTrap, (void**) &pSnmpTrap );
ISnmpMibBrowser *pSnmpMib;
CoCreateInstance(CLSID_SnmpMibBrowser, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpMibBrowser, (void**) &pSnmpMib );
ISsh *pSsh;
CoCreateInstance(CLSID_Ssh, NULL, CLSCTX_INPROC_SERVER, IID_ISsh, (void**) &pSsh );
ITcp *pTcp;
CoCreateInstance(CLSID_Tcp, NULL, CLSCTX_INPROC_SERVER, IID_ITcp, (void**) &pTcp );
ITftpServer *pTftpServer;
CoCreateInstance(CLSID_TftpServer, NULL, CLSCTX_INPROC_SERVER, IID_ITftpServer, (void**) &pTftpServer );
IUdp *pUdp;
CoCreateInstance(CLSID_Udp, NULL, CLSCTX_INPROC_SERVER, IID_IUdp, (void**) &pUdp );
IWOL *pWol;
CoCreateInstance(CLSID_WOL, NULL, CLSCTX_INPROC_SERVER, IID_IWOL, (void**) &pWOL );
Visual C++ samples are installed as part of the product, but can also be found on our website.
<html> <body> Version: <script language=vbscript runat=server> Set objTcp = CreateObject( "ActiveXperts.Tcp" ) Response.Write objTcp.Version </script> </body> </html>
Make sure the ActiveSocket Toolkit is installed on your system. For details about installation, click here.
First, add a reference to the ActiveSocket objects:
Create the various ActiveSocket object instances like this:
objConst : ISocketConstants; { Declaration of the interface class } objConst := TSocketConstants.Create(Form1).DefaultInterface; { Creation new instance of the object } objDnsServer : IDnsServer; { Declaration of the interface class } objDnsServer := TDnsServer.Create(Form1).DefaultInterface; { Creation new instance of the object } objDnsRecord : IDnsRecord; { Declaration of the interface class } objDnsRecord := TDnsRecord.Create(Form1).DefaultInterface; { Creation new instance of the object } objHttp : IHttp; { Declaration of the interface class } objHttp := THttp.Create(Form1).DefaultInterface; { Creation new instance of the object } objFtpServer : IFtpServer; { Declaration of the interface class } objFtpServer := TFtpServer.Create(Form1).DefaultInterface; { Creation new instance of the object } objFtpFile : IFtpFile; { Declaration of the interface class } objFtpFile := TFtpFile.Create(Form1).DefaultInterface; { Creation new instance of the object } objIcmp : IICmp; { Declaration of the interface class } objIcmp := TIcmp.Create(Form1).DefaultInterface; { Creation new instance of the object } objIPC : IIPtoCountry; { Declaration of the interface class } objIPC := TIPtoCountry.Create(Form1).DefaultInterface; { Creation new instance of the object } objMsn : IMsn; { Declaration of the interface class } objMsn := TMsn.Create(Form1).DefaultInterface; { Creation new instance of the object } objNtp : INtp; { Declaration of the interface class } objNtp := TNtp.Create(Form1).DefaultInterface; { Creation new instance of the object } objRsh : IRSh; { Declaration of the interface class } objRsh := TRSh.Create(Form1).DefaultInterface; { Creation new instance of the object } objScp : IScp; { Declaration of the interface class } objScp := TScp.Create(Form1).DefaultInterface; { Creation new instance of the object } objSFtpServer : ISFtpServer; { Declaration of the interface class } objSFtpServer := STFtpServer.Create(Form1).DefaultInterface; { Creation new instance of the object } objSFtpFile : ISFtpFile; { Declaration of the interface class } objSFtpFile := STFtpFile.Create(Form1).DefaultInterface; { Creation new instance of the object } objManager : ISnmpManager; { Declaration of the interface class } objManager := TSnmpManager.Create(Form1).DefaultInterface; { Creation new instance of the object } objSnmpObject : ISnmpObject; { Declaration of the interface class } objSnmpObject := TSnmpObject.Create(Form1).DefaultInterface; { Creation new instance of the object } objManager : ISnmpTrapManager; { Declaration of the interface class } objManager := TSnmpTrapManager.Create(Form1).DefaultInterface; { Creation new instance of the object } objData : ISnmpTrapData; { Declaration of the interface class } objData := TSnmpTrapData.Create(Form1).DefaultInterface; { Creation new instance of the object } objSnmpMib : ISnmpMibBrowser; { Declaration of the interface class } objSnmpMib := TSnmpMibBrowser.Create(Form1).DefaultInterface; { Creation new instance of the object } objSsh : ISsh; { Declaration of the interface class } objSsh := TSsh.Create(Form1).DefaultInterface; { Creation new instance of the object } objTcp : ITcp; { Declaration of the interface class } objTcp := TTcp.Create(Form1).DefaultInterface; { Creation new instance of the object } objTftpServer : ITftpServer; { Declaration of the interface class } objTftpServer := TFtpServer.Create(Form1).DefaultInterface; { Creation new instance of the object } objUdp : IUdp; { Declaration of the interface class } objUdp := TUdp.Create(Form1).DefaultInterface; { Creation new instance of the object } objWOL : IWOL; { Declaration of the interface class } objWOL := TWOL.Create(Form1).DefaultInterface; { Creation new instance of the object }
After these declarations and creation of the object(s), you can use the objects in your Delphi projects.
DNS is the Domain Name System. DNS converts machine names to the IP addresses that all machines on the net have. It translates (i.e. 'maps') from name to address and from address to name, and some other things.
The ActiveSocket DNS objects can be used to query servers running a domain name service (DNS) application. It will send domain name query packets to any designated DNS server. There are three data elements required in order to formulate a DNS query using ActiveSocket:
The ActiveSocket DNS objects are useful for gathering address information about hosts in the network. It can be used to query DNS for specific information about hosts, like mail exchanger records [MX], IP address [A], canonical names [CNAME], etc. If you have an IP address, you can get a canonical name back for the address and vice versa. Another useful feature is the ability to get a listing of hosts which serve mail exchange [MX] functions for a specific domain.
The following sample (VBScript) shows how the DnsServer and DnsRecord objects can be used to list all DNS records for a specific domain name:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create object Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Host = "ns1.interstroom.nl" ' DNS server objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Show all DNS records for activexperts.com WScript.Echo "Lookup, result: " & objDnsServer.LastError If( objDnsServer.LastError <> 0 ) Then WScript.Quit End If If ( objDnsServer.IsAuthoritative = True ) Then WScript.Echo "Server is an authority for this domain" Else WScript.Echo "Server is not an authority for this domain" End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Iterate over all DNS records; get first record While ( objDnsServer.LastError = 0 ) Select Case objDnsRecord.Type Case objConstants.asDNS_TYPE_A WScript.Echo "Type : A" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "IPv4 Address : " & objDnsRecord.Address Case objConstants.asDNS_TYPE_AAAA WScript.Echo "Type : AAAA" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "IPv6 Address : " & objDnsRecord.Address Case objConstants.asDNS_TYPE_CNAME WScript.Echo "Type : CNAME" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Alias : " & objDnsRecord.Address Case objConstants.asDNS_TYPE_MX WScript.Echo "Type : MX" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Preference : " & objDnsRecord.Preference WScript.Echo "Mail Exchange : " & objDnsRecord.MailExchange Case objConstants.asDNS_TYPE_NS WScript.Echo "Type : NS" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Name Server : " & objDnsRecord.NameServer Case objConstants.asDNS_TYPE_PTR WScript.Echo "Type : PTR" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Host : " & objDnsRecord.Address Case objConstants.asDNS_TYPE_SOA WScript.Echo "Type : SOA" WScript.Echo "Name : " & objDnsRecord.Name WScript.Echo "Name Server : " & objDnsRecord.NameServer WScript.Echo "MailBox : " & objDnsRecord.MailBox WScript.Echo "Serial : " & objDnsRecord.SerialNumber WScript.Echo "Refresh : " & objDnsRecord.RefreshInterval WScript.Echo "Retry Interval : " & objDnsRecord.RetryInterval WScript.Echo "Expiration Limit : " & objDnsRecord.ExpirationLimit WScript.Echo "Minimum TTL : " & objDnsRecord.MinimumTTL End Select WScript.Echo "TTL : " & objDnsRecord.TTL WScript.Echo Set objDnsRecord = objDnsServer.GetNextRecord ' Iterate over all DNS records; get next record Wend
| Property | Type | In/Out | Mand/Opt | Description |
| Name | String | Out | n/a | Name of the record |
| Type | Number | Out | n/a | Type of DNS record |
| Address | String | Out | n/a | IP address (or name of A record in case of CNAME) |
| TTL | Number | Out | n/a | Used as the default TTL for new records created within the zone |
| MailExchange | String | Out | n/a | The email address (replace @ with a dot) of the person responsible for maintenance of the zone |
| Preference | String | Out | n/a | MX preference |
| NameServer | String | Out | n/a | The domain name of the primary DNS server for the zone |
| MailBox | String | Out | n/a | The email address (replace @ with a dot) of the person responsible for maintenance of the zone |
| SerialNumber | String | Out | n/a | Used by secondary DNS servers to check if the zone has changed |
| RefreshInterval | Number | Out | n/a | How often secondary DNS servers should check if changes are made to the zone |
| RetryInterval | Number | Out | n/a | How often secondary DNS server should retry checking if changes are made - if the first refresh fails |
| ExpirationLimit | Number | Out | n/a | How long the zone will be valid after a refresh |
| MinimumTTL | Number | Out | n/a | Used as the default TTL for new records created within the zone |
| Function | Description |
| Clear | Reset all properties to their default values |
Type:
String
Description:
Name of the record.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any dns record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name WScript.Echo "Type: " & objDnsRecord.Type WScript.Echo "Address: " & objDnsRecord.Address End If
Type:
Number
Description:
Type of DNS record. Click here for a list of valid DNS types.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any dns record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name WScript.Echo "Type: " & objDnsRecord.Type WScript.Echo "Address: " & objDnsRecord.Address End If
Type:
String
Description:
IP Address, or name of A record (in case of a CNAME).
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any dns record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name WScript.Echo "Type: " & objDnsRecord.Type WScript.Echo "Address: " & objDnsRecord.Address End If
Type:
Number
Description:
Used as the default TTL for new records created within the zone.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any dns record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name WScript.Echo "TTL: " & objDnsRecord.TTL End If
Type:
String
Description:
The A Record for the mail server to connect to its IP-address. The 'MailExchange' property is only set for MX records.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_MX ' Lookup MX records for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name WScript.Echo "MailExchange: " & objDnsRecord.MailExchange WScript.Echo "Preference: " & objDnsRecord.Preference End If
Type:
Number
Description:
MX preference. An MX-record has a "Preference" number indicating the order in which the mail server should be used.
(Only relevant when multiple MX-records are defined for the same domain name).
Mail servers will attempt to deliver mail to the server with the lowest preference number first, and if unsuccessful continue with the next lowest and so on.
THe 'Preference' property is only set for MX records.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_MX ' Lookup MX records for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name WScript.Echo "MailExchange: " & objDnsRecord.MailExchange WScript.Echo "Preference: " & objDnsRecord.Preference End If
Type:
String
Description:
The domain name of the primary DNS server for the zone. Only applies to SOA (Start of Authority) records.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA ' Lookup SOA record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name ' Display all SOA record fields WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "MailBox: " & objDnsRecord.MailBox WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL End If
Type:
String
Description:
The email address (replace @ with a dot) of the person responsible for maintenance of the zone. The standard for this is the "hostmaster" username - such as "hostmaster.activexperts.com" (= hostmaster@activexperts.com). Only applies to SOA (Start of Authority) records.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA ' Lookup SOA record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name ' Display all SOA record fields WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "MailBox: " & objDnsRecord.MailBox WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL End If
Type:
String
Description:
Used by secondary DNS servers to check if the zone has changed. If the serial number is higher than what the secondary server has, a zone transfer will be initiated. Only applies to SOA (Start of Authority) records.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA ' Lookup SOA record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name ' Display all SOA record fields WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "MailBox: " & objDnsRecord.MailBox WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL End If
Type:
Number
Description:
How often secondary DNS servers should check if changes are made to the zone. Only applies to SOA (Start of Authority) records.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA ' Lookup SOA record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name ' Display all SOA record fields WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "MailBox: " & objDnsRecord.MailBox WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL End If
Type:
Number
Description:
How often secondary DNS server should retry checking if changes are made - if the first refresh fails. Only applies to SOA (Start of Authority) records.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA ' Lookup SOA record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name ' Display all SOA record fields WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "MailBox: " & objDnsRecord.MailBox WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL End If
Type:
Number
Description:
How long the zone will be valid after a refresh. Secondary servers will discard the zone if no refresh could be made within this interval. Only applies to SOA (Start of Authority) records.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA ' Lookup SOA record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name ' Display all SOA record fields WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "MailBox: " & objDnsRecord.MailBox WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL End If
Type:
Number
Description:
Minimum (default) TTL. Only applies to SOA (Start of Authority) records.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA ' Lookup SOA record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record If( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name ' Display all SOA record fields WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "MailBox: " & objDnsRecord.MailBox WScript.Echo "NameServer: " & objDnsRecord.NameServer WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL End If
Description:
Resets all properties to the initial, default values.
Parameters:
Return value:
Always 0.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record While( objDnsServer.LastError = 0 ) Then WScript.Echo "Name: " & objDnsRecord.Name objDnsRecord.Clear() ' Clear DNS record Set objDnsRecord = objDnsServer.GetNextRecord ' Get next DNS record WEnd
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version number of ActiveSocket |
| Build | String | Out | n/a | Display build information of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| Server | String | In/Out | O | Remote DNS Server's host name or IP address |
| ServerPort | Number | In/Out | O | DNS Server port. Default: 53 |
| LastError | Number | Out | n/a | Result of the last called function |
| LogFile | String | In/Out | O | Log file that can be used for troubleshooting purposes |
| Function | Description |
| Clear | Reset all properties to their default values |
| Lookup | Lookup DNS record(s) |
| GetFirstRecord | Get first DNS record |
| GetNextRecord | Get next DNS record |
| IsAuthoritative | Set to True if DNS server is authoritative |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Activate Software |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objDnsServer = CreateObject("ActiveXperts.DnsServer") ' Create a new DnsServer instance
WScript.Echo "Version: " & objDnsServer.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objDnsServer = CreateObject( "ActiveXperts.DnsServer" ) ' Create a new DnsServer object
WScript.Echo "Build: " & objDnsServer.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objDnsServer = CreateObject( "ActiveXperts.DnsServer" ) ' Create a new DnsServer instance
WScript.Echo "ExpirationDate: " & objDnsServer.ExpirationDate
Type:
String
Description:
Host name or IP address of the DNS server.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.xyz.intra" ' Remote DNS server: ns1.xyz.intra objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any record for activexperts.com ...
Type:
Number
Description:
TCP port number to identify a (remote) DNS server. If you don't specify the 'ServerPort' property, port 53 (default DNS port) is used.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.xyz.intra" ' Remote DNS server: ns1.xyz.intra objDnsServer.ServerPort = 8053 ' Use alternate port: 8053 objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any record for activexperts.com ...
Type:
Number
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any record for activexperts.com WScript.Echo "Lookup, result: " & objDnsServer.LastError ' Show result
Type:
String
Description:
For troubleshooting purposes, you can specify a log file to trace all DNS operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all DNS operations will be written to this log file.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.LogFile = "c:\dns.log" ' Set log file objDnsServer.Server = "ns1.interstroom.nl" objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ...
Description:
Resets all properties to the initial, default values.
Parameters:
Return value:
Always 0.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.xyz.intra" ' Remote DNS server: ns1.xyz.intra objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any record for activexperts.com ... objDnsServer.Clear ' Reset all properties objDnsServer.Server = "ns1.interstroom.nl" ' Remote DNS server: ns1.xyz.intra ...
Description:
Lookup DNS record(s).
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any dns record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record ...
Description:
Iterate over all DSN records that were a result of the Lookup query.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any dns record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If Set objDnsRecord = objDnsServer.GetFirstRecord ' Get first DNS record While( objDnsServer.LastError = 0 ) WScript.Echo "Name: " & objDnsRecord.Name ... Set objDnsRecord = objDnsServer.GetNextRecord ' Get next DNS record WEnd
Description:
Indicates if DNS server is authoritative for the queried domain.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objDnsServer.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Lookup any dns record for activexperts.com If( objDnsServer.LastError = 0 ) Then WScript.Quit End If WScript.Echo "IsAuthoritative: " & objDnsServer.IsAuthoritative() ' Is authoritative ?
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer") ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")
objDnsServer.Server = "ns1.interstroom.nl"
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY
WScript.Echo "LastError: " & objDnsServer.LastError
WScript.Echo "Error description: " & objDnsServer.GetErrorDescription( objDnsServer.LastError )
...
Description:
This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0.
Example:
Set objDnsServer = CreateObject( "ActiveXperts.DnsServer" ) ' Create DnsServer object Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object ... objDnsServer.Sleep 500
Description:
This function activates the ActiveSocket product. A valid registration code is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objDnsServer = CreateObject( "ActiveXperts.DnsServer" ) ' Create DnsServer object objDnsServer.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started.
FTP stands for File Transfer Protocol: a communication standard which allows computers to transfer files back and forth in spite of differences in how different operating systems handle file names, directories and file formats.
The local (client) computer is the one you're directly connected to, and the remote (server) computer is the one that you want to get files from or put files to. You need to specify the Internet address of the remote computer, e.g. ftp.activexperts-labs.com.
Some sites maintain archives of files for public use, permitting access using the username anonymous. Usually you are asked to enter your real e-mail address as the password. If a site is not using anonymous FTP, you must provide the username and password which has been assigned to you for that computer.
FTP programmes have different methods of handling plain-text files and binary files. The plain-text mode attempts to correct for the different ways that different operating systems handle line breaks in text files, while the binary mode ensures that all of the special non-printing bytes are transferred without change. HTML files are plain-text files, while word-processing documents and images are binary files.
The following sample (VBScript) shows how the FtpServer and FtpFile objects can be used to list files in a specific directory on an FTP server:
Set objFtpServer = CreateObject ( "ActiveXperts.FtpServer" ) objFtpServer.Connect "ftp.activexperts-labs.com","anonymous","" ' Connect to the FTP server using the anonymous account Wscript.Echo "Connect, result: " & objFtpServer.LastError If( objFtpServer.LastError <> 0 ) Then ' If connect failed then quit WScript.Quit End If objFtpServer.ChangeDir "samples/ASocket/Visual Basic/Telnet" ' Change directory Wscript.Echo "ChangeDir, result: " & objFtpServer.LastError If( objFtpServer.LastError <> 0 ) Then ' If ChangeDir fails then disconnect and quit objFtpServer.Disconnect WScript.Quit End If Set objFtpFile = objFtpServer.FindFirstFile() ' Iterate over all files in dir. Start with first file While( objFtpServer.LastError = 0 ) WScript.Echo "Name: " & objFtpFile.Name ' Display file name WScript.Echo "IsDirectory: " & objFtpFile.IsDirectory ' Display directory or file WScript.Echo "Size: " & objFtpFile.Size ' Display file size WScript.Echo "Date: " & objFtpFile.Date ' Display file date ' To save the file, call the GetFile function. ' strSaveAs = "C:\temp\" & objFtpFile.Name ' objFtpServer.GetFile objFtpFile.Name, strSaveAs ' Wscript.Echo "Save file, result: " & objFtpServer.LastError ' To delete a file, call the DeleteFile function. ' objFtpServer.DeleteFile objFtpFile.Name ' Wscript.Echo "Delete, result: " & objFtpServer.LastError Set objFtpFile = objFtpServer.FindNextFile() ' Next file Wend objFtpServer.Disconnect ' Disconnect
| Property | Type | In/Out | Mand/Opt | Description |
| Name | String | Out | n/a | Filename |
| IsDirectory | Boolean | Out | n/a | Is the file a directory (True) or a file (False) |
| Size | Number | Out | n/a | Size of file (in bytes) |
| DateSeconds | Number | Out | n/a | Last modification date of the file (in seconds after 1/1/1970) |
| Date | String | Out | n/a | Last modification date of the file (as a friendly string) |
| Function | Description |
| None | No functions defined for the FtpFile object |
Type:
String
Description:
File name.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.Connect( "ftp01", "myaccount", "mypassword" ) ' Connect to the FTP server ... Set objFtpFile = objFtpServer.FindFirstFile() ' Get first file in the directory If( objFtpServer.LastError = 0 ) Then WScript.Echo "Name : " & objFtpFile.Name ' Display name of the file WScript.Echo "IsDirectory : " & objFtpFile.IsDirectory WScript.Echo "Size (in bytes) : " & objFtpFile.Size WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds WScript.Echo "Date : " & objFtpFile.Date End If ... objFtpServer.Disconnect ' Disconnect
Type:
Boolean
Description:
True indicates a directory, False indicates a file.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.Connect( "ftp01", "myaccount", "mypassword" ) ' Connect to the FTP server ... Set objFtpFile = objFtpServer.FindFirstFile() ' Get first file in the directory If( objFtpServer.LastError = 0 ) Then WScript.Echo "Name : " & objFtpFile.Name WScript.Echo "IsDirectory : " & objFtpFile.IsDirectory ' Display: Directory or File WScript.Echo "Size (in bytes) : " & objFtpFile.Size WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds WScript.Echo "Date : " & objFtpFile.Date End If ... objFtpServer.Disconnect ' Disconnect
Type:
Number
Description:
Size (in bytes) of the file.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.Connect( "ftp01", "myaccount", "mypassword" ) ' Connect to the FTP server ... Set objFtpFile = objFtpServer.FindFirstFile() ' Get first file in the directory If( objFtpServer.LastError = 0 ) Then WScript.Echo "Name : " & objFtpFile.Name WScript.Echo "IsDirectory : " & objFtpFile.IsDirectory WScript.Echo "Size (in bytes) : " & objFtpFile.Size ' Display size in bytes WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds WScript.Echo "Date : " & objFtpFile.Date End If ... objFtpServer.Disconnect ' Disconnect
Type:
Number
Description:
Last modification date and time of the file, in seconds after 1/1/1970.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.Connect( "ftp01", "myaccount", "mypassword" ) ' Connect to the FTP server ... Set objFtpFile = objFtpServer.FindFirstFile() ' Get first file in the directory If( objFtpServer.LastError = 0 ) Then WScript.Echo "Name : " & objFtpFile.Name WScript.Echo "IsDirectory : " & objFtpFile.IsDirectory WScript.Echo "Size (in bytes) : " & objFtpFile.Size WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds ' Display last modification date/time in seconds after 1/1/1970 WScript.Echo "Date : " & objFtpFile.Date End If ... objFtpServer.Disconnect ' Disconnect
Type:
String
Description:
Last modification and time of the file, as a friendly string.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.Connect( "ftp01", "myaccount", "mypassword" ) ' Connect to the FTP server ... Set objFtpFile = objFtpServer.FindFirstFile() ' Get first file in the directory If( objFtpServer.LastError = 0 ) Then WScript.Echo "Name : " & objFtpFile.Name WScript.Echo "IsDirectory : " & objFtpFile.IsDirectory WScript.Echo "Size (in bytes) : " & objFtpFile.Size WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds WScript.Echo "Date : " & objFtpFile.Date ' Display modification date/time as a friendly string End If ... objFtpServer.Disconnect ' Disconnect
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version number of ActiveSocket |
| Build | String | Out | n/a | Display build information of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| HostPort | Number | In/Out | O | TCP port of the remote FTP server. Default: 21 |
| PassiveMode | Boolean | In/Out | O | Specifies how to connect: passive (default) or active |
| BinaryTransfer | Boolean | In/Out | O | Specifies how to transfer files: binary (default) or ASCII |
| LastError | Number | Out | n/a | Result of the last called function |
| LastResponse | String | Out | n/a | Last response from FTP server |
| LogFile | String | In/Out | O | Log file for troubleshooting purposes |
| Function | Description |
| Clear | Reset all properties to their default values |
| Connect | Connect to a remote FTP server |
| Disconnect | Close the connection |
| GetCurrentDir | Retrieve the current directory |
| ChangeDir | Change directory |
| CreateDir | Create directory |
| RenameDir | Rename directory |
| DeleteDir | Delete directory |
| FindFile | Find a file in the current directory |
| FindFirstFile | Find first file in the current directory |
| FindNextFile | Find next file in the current directory |
| RenameFile | Rename a file in the current directory |
| DeleteFile | Delete a file in the current directory |
| GetFile | Download (get) a file from the current directory |
| PutFile | Upload (put) a file to the current directory |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Suspends the execution of the object for at least the specified interval |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objFtpServer = CreateObject("ActiveXperts.FtpServer") ' Create a new FtpServer instance
WScript.Echo "Version: " & objFtpServer.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer object
WScript.Echo "Build: " & objFtpServer.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
WScript.Echo "ExpirationDate: " & objFtpServer.ExpirationDate
Type:
Number
Description:
TCP port number to identify a (remote) FTP server. If you don't specify the 'HostPort' property, port 21 (default FTP port) is used.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.HostPort = 8021 ' Use port 8021 instead of default port 21 objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 on port 8021 ...
Type:
Boolean
Description:
Specifies the way to connect to the remote FTP server: in Passive mode or in Active mode. Default value: True (Passive)
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.PassiveMode = False ' Use Active mode instead of the default Passive mode objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 in Active mode ...
Type:
Boolean
Description:
Specifies the way files are transfered when downloading (GetFile) or uploading (PutFile) files. Default value: True, indicating that files are tranferred in binary mode by default.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 ... objFtpServer.BinaryMode = False ' Files transfer in ASCII mode when using GetFile/PutFile Set objFtpFile = objFtpServer.GetFile( "c:\temp\log1.txt", "/logfiles/log1.txt" ) ' Download log1.txt in ASCII mode
Type:
Number
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 WScript.Echo "LastError: " & objFtpServer.LastError ...
Type:
String
Description:
The last response of an FTP operation is stored in the 'LastResponse' property. It can be used for troubleshooting purposes.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 WScript.Echo "LastResponse: " & objFtpServer.LastResponse ' Display the last response from the FTP server ...
Type:
String
Description:
For troubleshooting purposes, you can specify a log file to trace all FTP operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all FTP operations will be written to this log file.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.LogFile = "C:\Ftp.log" ' Write all FTP operations to the specified log file ... objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 ...
Description:
Resets all properties to the initial, default values.
Parameters:
Return value:
Always 0.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 ... objFtpServer.Disconnect ' Disconnect objFtpServer.Clear ' Clear properties before connecting to another FTP server objFtpServer.Connect "ftpserver2", "account", "pwd" ' Connect to host ftpserver2
Description:
Call this function to connect to a remote FTP server. By default, a Passive connection will be established. If you want to establish a connection in Active mode, you should set the PassiveMode flag to False.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.ChangeDir( "/pictures" ) ... objFtpServer.Disconnect End If
Description:
Call this function to close a connnection that was established using the Connect function.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.Disconnect ' Close the session End If
Description:
The directory string. If the function fails, an empty string is returned and the LastError property is set to a non-zero value indicating the reason for failing.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... strCurrentDir = objFtpServer.GetCurrentDir() ' Retrieve current directory If( objFtpServer.LastError = 0 ) Then WScript.Echo "Current Directory: " & strCurrentDir End If objFtpServer.Disconnect ' Close the session End If
Description:
Change the current directory on the remote FTP server. You can use a fully qualified directory name, or a plain directory name.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.ChangeDir( "/pictures" ) ' Change directory to: /pictures objFtpServer.ChangeDir( "family" ) ' Change directory to: /pictures/family ... objFtpServer.ChangeDir( "/pictures/friends" ) ' Change directory to: /pictures/friends ... objFtpServer.Disconnect ' Close the session End If
Description:
Create a new directory on the remote FTP server in the directory indicated by GetCurrentDir.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.ChangeDir( "/pictures" ) ' Change directory to: /pictures objFtpServer.CreateDir( "family" ) ' Create new directory 'family' ... objFtpServer.Disconnect ' Close the session End If
Description:
Rename directory.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.RenameDir( "pictures", "images" ) ' Rename directory 'pictures' into 'images' ... objFtpServer.Disconnect ' Close the session End If
Description:
Delete a directory.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.ChangeDir( "/pictures" ) ' Change directory to: /pictures objFtpServer.DeleteDir( "family" ) ' Delete directory 'family' ... objFtpServer.Disconnect ' Close the session End If
Description:
Find a file. You can use a plain filename (the file will then be retrieved from the current directory) or you can use a fully qualified filename.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then Set objFtpFile1 = objFtpServer.FindFile( "/pictures/picture1.jpg") ' Find file using a fully qualified filename ... objFtpServer.ChangeDir( "/pictures" ) Set objFtpFile2 = objFtpServer.FindFile( "picture2.jpg") ' Find file using a plain filename objFtpServer.Disconnect ' Close the session End If
Description:
Iterate of all files and directories in the current directory. The 'FindFirstFile' function retrieves the first file/directory. You can call 'FindNextFile' until there are no more files/directories.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then Set objFtpFile = objFtpServer.FindFirstFile() While( objFtpServer.LastError = 0 ) WScript.Echo "File: " & objFtpFile.Name ' Display filename (or directoryname) Set objFtpFile = objFtpServer.FindNextFile() WEnd objFtpServer.Disconnect ' Close the session End If
Description:
Rename file.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.ChangeDir( "/pictures" ) ' Change directory to: /pictures objFtpServer.Rename( "old.jpg", "new.jpg" ) ' Rename 'old.jpg' into 'new.jpg' ... objFtpServer.Disconnect ' Close the session End If
Description:
Delete file.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.ChangeDir( "/pictures" ) ' Change directory to: /pictures objFtpServer.Delete( "picture1.jpg" ) ' Delete 'picture1.jpg' ... objFtpServer.Disconnect ' Close the session End If
Description:
Download a file from the FTP server.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.ChangeDir( "/pictures" ) ' Change directory to: /pictures objFtpServer.GetFile( "picture1.jpg", "c:\pictures\file1.jpg" ) ' Download 'picture1.jpg' ... objFtpServer.ChangeDir( "/" ) ' Change directory to: / objFtpServer.GetFile( "/pictures/picture1.jpg", "c:\pictures\file1.jpg" ) ' Download 'picture2.jpg' objFtpServer.Disconnect ' Close the session End If
Description:
Upload a file to the FTP server.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 If( objFtpServer.LastError = 0 ) Then ... objFtpServer.ChangeDir( "/pictures" ) ' Change directory to: /pictures objFtpServer.PutFile( "c:\pictures\picture3.jpg", "/pictures/picture3.jpg" ) ' Upload 'picture3.jpg' ... objFtpServer.PutFile( "c:\pictures\picture4.jpg", "/pictures/picture4.jpg" ) ' Upload 'picture4.jpg' End If
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance ... objFtpServer.Connect "ftpserver1", "account", "pwd" ' Connect to host ftpserver1 WScript.Echo "LastError: " & objFtpServer.LastError WScript.Echo "Error description: " & objFtpServer.GetErrorDescription( objFtpServer.LastError ) ...
Description:
This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create Ftperver object Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object ... objFtpServer.Sleep 50
Description:
This function activates the ActiveSocket product. A valid registration code is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create FtpServer object objFtpServer.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started.
Today, there are many software packages available to check web sites, like availability, contents, bandwidth, changes, etc..
However, most of these software tools are stand-alone packages, without scripting options.
ActiveSocket is very well suited for scripting and embedding in applications.
The ActiveSocket Http object allows you to read web pages completely, so you can perform your own content checking. Use the ActiveSocket Http object to:
The ActiveSocket Http object doesn't require direct Internet access; it can operate through a proxy server (incl. support for proxy authentication). It also supports SSL secure web sites, including authentication.
Here is a small example (in VBScript) to show how to use the Http object:
Set objHttp = CreateObject("ActiveXperts.Http") ' Create HTTP object
objHttp.Connect( "www.activexperts.com/products" ) ' Connect to a remote server
WScript.Echo "Connect, result: " & objHttp.LastError
If( objHttp.LastError <> 0 ) Then
WScript.Quit
End If
' Connection esablished; ready to read data
strData = objHttp.ReadData ' Read data stream
If( objHttp.LastError <> 0 ) Then
WScript.Echo "Error " & objHttp.LastError ' Failed to read data, print the error
Else
WScript.Echo strData ' Show data
End If
objHttp.Disconnect ' Disconnect
WScript.Echo "Ready."
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version number of ActiveSocket |
| Build | String | Out | n/a | Display build information of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| LastError | Number | Out | n/a | Result of the last called function |
| UseSSL | Bool | In/Out | n/a | Access the page through SSL |
| UsePost | Bool | In/Out | n/a | Specify to use HTTP-POST instead of HTTP-GET |
| PostData | String | In/Out | O | Data to send with HTTP POST |
| RequestTimeout | Number | In/Out | O | Timeout value for HTTP requests |
| KeepAlive | Bool | In/Out | n/a | Specify to use the keepalive flag in the HTTP header |
| HttpLibrary | String | In/Out | O | The preferred Http interface library |
| ProxyServer | String | In/Out | O | Use a proxy server |
| ProxyAccount | String | In/Out | O | Use this account for proxy authentication |
| ProxyPassword | String | In/Out | O | Use this password for proxy authentication |
| WebAccount | String | In/Out | O | Use this account to authenticate at the web site |
| WebPassword | String | In/Out | O | Use this password to authenticate at the web site |
| LogFile | String | In/Out | O | Log file; use it for troubleshooting purposes |
| Function | Description |
| Clear | Reset all properties to default |
| Connect | Connect to a web site |
| Disconnect | Disconnect from a web site |
| ReadHeader | Read HTTP header |
| ReadData | Read data from the web page |
| GetErrorDescription | Get the error description |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Activate the product |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
WScript.Echo "Version: " & objHttp.Version
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objHttp = CreateObject( "ActiveXperts.Http" ) ' Create Http object
WScript.Echo "Build: " & objHttp.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it. Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objHttp = CreateObject( "ActiveXperts.Http" ) ' Create Http object
Response.Write "ExpirationDate: " & objHttp.ExpirationDate
Type:
Number
Description:
The result of a previous called function. Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com"
WScript.Echo "LastError: " & objHttp.LastError
Type:
Boolean
Description:
Set this property to indicate that the Connect function must access the page through SSL. Connect discards the 'http://' and 'https://' prefixes, so settings the 'UseSSL' property is the only way to tell the Http object to use SSL.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.UseSSL = True
...
objHttp.Connect "www.activexperts.com" ' To access https://www.activexperts.com
Type:
Boolean
Description:
Set this property to indicate that the Connect function must request the page using HTTP-POST.
HTTP-POST is used to send a large number of bytes as parameters to a webserver.
The default value is disabled (use HTTP-GET).
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.UsePost = True
...
objHttp.Connect "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200" ' HTTP/Post
Type:
String
Description:
When the UsePost property is set, you can use this property to send additional data with the HTTP POST request.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.UsePost = True
objHttp.PostData = "a1=1;a2=2"
...
objHttp.Connect "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200" ' HTTP/Post
Type:
Number
Description:
By default the HTTP request timeout is set to 10 seconds. For large webpages, or pages that need to do some processing, you can use this property to increase the timeout. The value is specified in seconds.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.RequestTimeout = 20
...
objHttp.Connect "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200"
Type:
Boolean
Description:
Set this property to indicate that 'KeepAlive' value in the HTTP header is set to TRUE. This required for some rarely used authentication algorithms.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.KeepAlive = True
...
objHttp.Connect "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200"
Type:
Number
Description:
ActiveSocket makes use of the WinHTTP library of the operating system.
By default, the 'HttpLibrary' property is emtpy,
and ActiveSocket will attempt to load WinHTTP5.dll. If WinHTTP5.dll fails to load, it will attempt to load WinHTTP.dll.
If you prefer another WinHTTP library, you can set the 'HttpLibrary' property. If set, ActiveSocket will ONLY attempt to load the specified library, it will not try other libraries after that.
The 'HttpLibrary' property is used by the Connect function, so you must assign a value to it BEFORE calling the Connect function.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.HttpLibrary = "winhttp.dll" ' Load winhttp.dll
...
objHttp.Connect "www.activexperts.com"
Type:
String
Description:
If your Internet configuration requires access to a proxy server, you must assign the host name or IP address of the proxy server to the 'ProxyServer' property. Optionally, if proxy authentication is required, assign the proxy authentication values to the 'ProxyAccount' and 'ProxyPassword' properties. The proxy properties are used by the Connect function, so you must assign values to the proxy properties BEFORE calling the Connect function.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.ProxyServer = "proxy01.intranet.dom" ' Access through a proxy
objHttp.ProxyAccount = "mjackson" ' Proxy authentication required
objHttp.ProxyPassword = "mjackson1" ' Proxy authentication required
...
objHttp.Connect "www.activexperts.com"
Type:
String
Description:
If access to the web page requires authentication, you must assign the 'WebAccount' and 'WebPassword' properties. The 'WebAccount' and 'WebPassword' properties are used by the Connect function, so you must assign values to these properties BEFORE calling the Connect function.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.WebAccount = "user_a" ' Website requires authentication
objHttp.WebPassword = "password_a" ' Website requires authentication
objHttp.Connect "www.activexperts.com:80/about"
Type:
String
Description:
For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.LogFile = "c:\file.log"
objHttp.Connect "www.activexperts.com:80/about"
Description:
Resets all properties to the initial value.
Parameters:
Return value:
Always 0.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com:8080/products/"
If( objHttp.LastError = 0 ) Then
...
End If
Description:
Connect to a web page. You must connect to a web page before you can use the ReadData to actually read the data from the page. The 'Connect' function requires one parameter: the URL. The 'http://' and 'https://' prefixes are ignored by the 'Connect' function. You can include a port number and a relative path in the URL.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com:8080/products/"
If( objHttp.LastError = 0 ) Then
...
End If
Description:
Disconnect from a web site. You must disconnect from a web page when you don't want to read data from the page anymore. The 'Disconnect' function only disconnects a session if you already made a connection to the page though the Connect function. If there is no connection, 'Disconnect' returns immediately with no error.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com/products"
If( objHttp.LastError = 0 ) Then
...
objHttp.Disconnect
End If
Description:
Read all data from the web page. You must connect to a web page before you can read the data from the page.
Parameters:
Return value:
The data that was read from the web page. If the function fails, an empty string is returned and LastError property is set.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com"
If( objHttp.LastError = 0 )
strData = objHttp.ReadData
If( objHttp.LastError = 0 )
WScript.Echo strData
End If
End If
Description:
Read the HTTP header of the site you are connecting to. You must connect to a web page before you can read the HTTP header from the remote site.
Parameters:
Return value:
The header that was read from the site. If the function fails, an empty string is retunred and LastError property is set.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com"
If( objHttp.LastError = 0 )
strData = objHttp.ReadHeader( 1 ) ' 1 means: Content-type
WScript.Echo strData
strData = objHttp.ReadHeader( 3 ) ' 3 means: Content-ID
WScript.Echo strData
strData = objHttp.ReadHeader( 35 ) ' 35 means: Referer
WScript.Echo strData
End If
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.thispagedoesnotexist.dom/about"
WScript.Echo "LastError: " & objHttp.LastError
WScript.Echo "Error description: " & objHttp.GetErrorDescription( objHttp.LastError )
Description:
This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0.
Example:
Set objHttp = CreateObject( "ActiveXperts.Http" ) ' Create Http object
...
objHttp.Sleep 500
Description:
This function activates the ActiveSocket product. A valid registration code is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objHttp = CreateObject( "ActiveXperts.Http" ) ' Create Http object objHttp.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started.
The HttpEx object provides a very simple interface to commonly used HTTP functions. This object uses connection pooling to speed up multiple calls to the same webserver. This will enhance performance for applications which need to get an entire web page including images, stylesheets, scriptfiles etc..
The function calls used in this object are analogous to the verbs that are used in the HTTP protocol. For instance, the http GET verb, which is the default way for a browser to query a web page, is translated to the 'Get' function.
In addition this object supports the use of proxy servers and webauthentication. If also supports SSL and TLS encryption methods.
Here is a small example (in VBScript) to show how to use the HttpEx object:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx") ' Create HttpEx object
WScript.Echo objHttpEx.Get( "www.activexperts.com/products" ) ' Echo the contents of the products page
If( objHttpEx.LastError <> 0 ) Then
WScript.Echo "Error " & objHttpEx.LastError ' Failed to get the web page, print the error
End If
WScript.Echo "Ready."
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version number of ActiveSocket |
| Build | String | Out | n/a | Display build information of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| LastError | Number | Out | n/a | Result of the last called function |
| LastResponseCode | Number | Out | n/a | Last HTTP response code |
| RequestTimeout | Number | In/Out | O | Timeout value for HttpEx requests |
| ConnectionExpireTimeout | Number | In/Out | O | Timeout value for connections to expire and be elegible for removal from the connection pool |
| ConnectionPoolSize | Number | In/Out | O | The number of active connection that can be kept in the connection pool at one time |
| UserAgent | String | In/Out | O | The user agent string that will be provided when making requests or posts |
| ProxyServer | String | In/Out | O | Use a proxy server |
| ProxyAccount | String | In/Out | O | Use this account for proxy authentication |
| ProxyPassword | String | In/Out | O | Use this password for proxy authentication |
| WebAccount | String | In/Out | O | Use this account to authenticate at the web site |
| WebPassword | String | In/Out | O | Use this password to authenticate at the web site |
| LogFile | String | In/Out | O | Log file; use it for troubleshooting purposes |
| Function | Description |
| Clear | Reset all properties to default |
| Get | Gets the contents of a website as a string using an HTTP GET request |
| GetFile | Downloads the contents of a website to a file using an HTTP GET request |
| Head | Gets the headers for a website using the HTTP HEAD command |
| Post | Post string data to a webpage and returns the response as a string using the HTTP POST command |
| AddHeader | Adds a custom header to future GET or POST requests |
| UrlEncode | Url Encode a given string |
| GetErrorDescription | Get the error description |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Activate the product |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
WScript.Echo "Version: " & objHttpEx.Version
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objHttpEx = CreateObject( "ActiveXperts.HttpEx" ) ' Create HttpEx object
WScript.Echo "Build: " & objHttpEx.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it. Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objHttpEx = CreateObject( "ActiveXperts.HttpEx" ) ' Create HttpEx object
Response.Write "ExpirationDate: " & objHttpEx.ExpirationDate
Type:
Number
Description:
The result of a previous called function. Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
objHttpEx.Get "www.activexperts.com"
WScript.Echo "LastError: " & objHttpEx.LastError
Type:
Number
Description:
The last received HTTP response code. Use this to check the HTTP response after a Get, Post or Head function call. When a HTTP call succeeded the response code should be 200 (Ok). More information about HTTP response codes can be found here.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
objHttpEx.Get "www.activexperts.com"
WScript.Echo "LastError: " & objHttpEx.LastError
Wscript.Echo "HTTP Response: " & objHttpEx.LastResponseCode
Type:
Number
Description:
For large webpages, or pages that need to do some processing, you can use this property to increase the timeout. By default the HttpEx request timeout is set to 10 seconds. The value is specified in milliseconds.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
objHttpEx.RequestTimeout = 20000
...
objHttpEx.Get "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200"
Type:
Number
Description:
Timeout value for connections to expire and be elegible for removal from the connection pool. By default the ConnectionExireTimeout is set to 30 seconds. The value is specified in milliseconds.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
objHttpEx.ConnectionExpireTimeout = 300000
...
objHttpEx.Get "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200"
Type:
Number
Description:
The number of active connection that can be kept in the connection pool at one time. If the connection pool is full expired connections will be removed. If no connections have expired the oldest connection will be removed in favor of the new connection. By default this value is set to 32.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
objHttpEx.ConnectionPoolSize = 5
...
objHttpEx.Get "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200"
Type:
Boolean
Description:
Set this property to indicate which user agent is used to connect to a website. Some webservers will host different pages according to browser vendor or version.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
objHttpEx.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3)"
...
objHttpEx.Get "www.activexperts.com"
Type:
String
Description:
If your Internet configuration requires access to a proxy server, you must assign the host name or IP address of the proxy server to the 'ProxyServer' property. Optionally, if proxy authentication is required, assign the proxy authentication values to the 'ProxyAccount' and 'ProxyPassword' properties. The proxy properties are used by the Get, GetFile, Post and Head functions, so you must assign values to the proxy properties BEFORE calling either of these functions.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
objHttpEx.ProxyServer = "proxy01.intranet.dom" ' Access through a proxy
objHttpEx.ProxyAccount = "mjackson" ' Proxy authentication required
objHttpEx.ProxyPassword = "mjackson1" ' Proxy authentication required
...
objHttpEx.Get "www.activexperts.com"
Type:
String
Description:
If access to the web page requires authentication, you must assign the 'WebAccount' and 'WebPassword' properties. The 'WebAccount' and 'WebPassword' properties are used by the Get, GetFile, Post and Head functions, so you must assign values to the proxy properties BEFORE calling either of these functions.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
objHttpEx.WebAccount = "user_a" ' Website requires authentication
objHttpEx.WebPassword = "password_a" ' Website requires authentication
objHttpEx.Get "www.activexperts.com:80/about"
Type:
String
Description:
For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
objHttpEx.LogFile = "c:\file.log"
objHttpEx.Get "www.activexperts.com:80/about"
Description:
Resets all properties to the initial value.
Parameters:
Return value:
Always 0.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
objHttpEx.AddHeader "Connection", "Keep-Alive"
objHttpEx.Clear
objHttpEx.Get "www.activexperts.com:8080/products/"
If( objHttpEx.LastError = 0 ) Then
...
End If
Description:
Get the contents of a webpage from a webserver and return it as a string value. This function defaults to non secure connections using the default HTTP port 80. The use of SSL or a diffent port can be specified as usual, e.g. https://cruisecontrol.intra:8080/dashboard connects securely on port 8080.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
WScript.Echo objHttpEx.Get("www.activexperts.com:8080/products/")
If( objHttpEx.LastError = 0 ) Then
...
End If
Description:
Get the contents of a webpage from a webserver and save it to a file. This function defaults to non secure connections using the default HTTP port 80. The use of SSL or a diffent port can be specified as usual, e.g. https://cruisecontrol.intra:8080/dashboard connects securely on port 8080.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
objHttpEx.GetFile "www.activexperts.com:8080/products/", "C:\products.txt"
If( objHttpEx.LastError = 0 ) Then
...
End If
Description:
Get the headers of a webpage from a webserver and return it as a string value. This function defaults to non secure connections using the default HTTP port 80. The use of SSL or a diffent port can be specified as usual, e.g. https://cruisecontrol.intra:8080/dashboard connects securely on port 8080.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
WScript.Echo objHttpEx.Head("www.slashdot.org")
If( objHttpEx.LastError = 0 ) Then
...
End If
Description:
Post a string to a website and returns the result as a string value. This function defaults to non secure connections using the default HTTP port 80. The use of SSL or a diffent port can be specified as usual, e.g. https://cruisecontrol.intra:8080/dashboard connects securely on port 8080.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
WScript.Echo objHttpEx.Post("www.activexperts.com:8080/products/", "COMPANY_NAME=test&COMPANY_URL=http://example.com")
If( objHttpEx.LastError = 0 ) Then
...
End If
Description:
Adds a custom header to the next request or post that is made to a webserver. To remove any added header value call the Clear function.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
objHttpEx.AddHeader("Connection", "Keep-Alive")
WScript.Echo objHttpEx.Get("http://www.activexperts.com")
If( objHttpEx.LastError = 0 ) Then
...
End If
Description:
UrlEncode function encodes the given string. Use this function to encode parameters when using HttpEx to 'POST' or 'GET' specific parameters to a website.
Parameters:
Return value:
An encoded copy of the input string
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
Url = "http://www.google.com/search?hl=en&q=" & objHttpEx.UrlEncode("Hello, World !")
Wscript.Echo objHttpEx.Get(Url)
WScript.Echo "LastError: " & objHttpEx.LastError
WScript.Echo "Error description: " & objHttpEx.GetErrorDescription( objHttpEx.LastError )
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objHttpEx = CreateObject("ActiveXperts.HttpEx")
...
objHttpEx.Get "www.thispagedoesnotexist.dom/about"
WScript.Echo "LastError: " & objHttpEx.LastError
WScript.Echo "Error description: " & objHttpEx.GetErrorDescription( objHttpEx.LastError )
Description:
This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0.
Example:
Set objHttpEx = CreateObject( "ActiveXperts.HttpEx" ) ' Create HttpEx object
...
objHttpEx.Sleep 500
Description:
This function activates the ActiveSocket product. A valid registration code is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objHttpEx = CreateObject( "ActiveXperts.HttpEx" ) ' Create HttpEx object objHttpEx.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started.
ICMP/Ping is one of the most commonly used utilities on the Internet by people and programs, with untold millions of pings flashing every second back and forth between computers. The original PING utility stood for "Packet Internet Groper", and was a package of diagnostic utilities used by DARPA personnel to test the performance of the ARPANET. Almost every operating system includes a Ping program. It has become one of the most versatile and widely used diagnostic tools on the Internet.
ICMP/Ping sends a small packet of information containing an ICMP ECHO_REQUEST to a specified computer, which then sends an ECHO_REPLY packet in return.
You can use Ping to perform several useful network diagnostics, such as the following:
The ActiveSocket Icmp object enables you to add Icmp/Ping functionality to your program.
Here is a small example (in VBScript) to show how to use the Icmp object:
Set objIcmp = CreateObject("ActiveXperts.Icmp") ' Create Icmp object
objIcmp.Ping "www.activexperts.com", 2000 ' Ping host; timeout 2000 ms
If( objIcmp.LastError = 0 ) Then
WScript.Echo "Success, duration: " & objIcmp.LastDuration & "ms"
Else
WScript.Echo "Error " & objIcmp.LastError & ": " & objIcmp.GetErrorDescription( objIcmp.LastError )
End If
WScript.Echo "Ready."
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version number of ActiveSocket |
| Build | String | Out | n/a | Display build information of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| LogFile | String | In/Out | n/a | Log file; use it for troubleshooting purposes |
| Ttl | Number | In/Out | No | Maximum Time To Live in next Ping call |
| BufferSize | Number | In/Out | No | Send buffer size |
| LastError | Number | Out | n/a | Result of the last called function |
| LastDuration | Number | Out | n/a | Reply time of the last Ping call |
| LastTtl | Number | Out | n/a | TTL of last Ping call |
| Function | Description |
| Clear | Clear all properties |
| Ping | Ping the specified host |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
WScript.Echo "Version: " & objIcmp.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
WScript.Echo "Build: " & objIcmp.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
WScript.Echo "ExpirationDate: " & objIcmp.ExpirationDate
Type:
String
Description:
For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
objIcmp.LogFile = "c:\file.log
Type:
Number
Description:
Time To Live to be used in the next Ping call. Value must be between 1 and 255. Default value is 255.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) objIcmp.Ttl = 100 ' Use a different Time To Live than the default 255 value objIcmp.Ping "www.monitortools.com", 2000 ' Ping monitortools.com, timeout after 2000 msec If( objIcmp.LastError = 0 ) Then WScript.Echo "TTL: " & objIcmp.LastTtl End If
Type:
Number
Description:
Buffer size (in bytes) to be used in the next Ping call. Value must be between 0 and 8192. Default value is 32 (bytes).
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object objIcmp.BufferSize = 64 ' Use a different buffer size than the default (32 bytes) objIcmp.Ping "www.monitortools.com", 2000 ' Ping monitortools.com, timeout after 2000 msec
Type:
Number
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
objIcmp.Ping "server.mydomain.com", 2000
WScript.Echo "LastError: " & objIcmp.LastError
Type:
Number
Description:
The duration of the last Ping call. The property is read-only; you cannot assign a value to it.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
objIcmp.Ping "www.activexperts.com", 2000
WScript.Echo "Duration of ICMP/Ping operation: " & objIcmp.LastDuration
Type:
Number
Description:
The Time To Live value of the last Ping call. The property is read-only; you cannot assign a value to it.
The maximum Time To Live value is indicated by the Ttl property. The default maximum Time To Live value is 255, but you can assign any value between 1 and 255 to it.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
objIcmp.Ping "www.monitortools.com", 2000
If( objIcmp.LastError = 0 ) Then
WScript.Echo "TTL: " & objIcmp.LastTtl
End If
Description:
Reset all properties to their initial values. Use this function when you make consecutive calls to the Ping function.
Parameters:
Return value:
Always 0.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
objIcmp.Ping "192.168.1.1", 2000
objIcmp.Clear
objIcmp.Ping "192.168.1.2", 2000
Description:
Ping the specified host. The function requires one parameter: the host that you want to check.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
objIcmp.Ping "192.168.1.1", 2000
objIcmp.Clear
objIcmp.Ping "192.168.1.2", 2000
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
objIcmp.Ping "www.thisdoesnotexist.com", 2000
WScript.Echo "LastError: " & objIcmp.LastError
WScript.Echo "Error description: " & objIcmp.GetErrorDescription( objIcmp.LastError )
Description:
This function can be used in your script anywhere you want. Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0.
Example:
Set objIcmp = CreateObject( "ActiveXperts.Icmp" ) ' Create Icmp object
...
objIcmp.Sleep 500
Today there are millions of internet users around the world. There are also numerous products and services available on the internet.
There are some key benefits of determines the country by IP address:
The IPtoCountry object translates IP address to countries. It makes use of an internal IP-to-Coiuntry database, which resides as a data segment in the ActiveSocket core component: ASocket.dll. The accuracy is over 95%. The inaccuracy is due to dynamic IP address allocation by large ISPs such as AOL and MSN TV. It is also due to the use of proxy servers.
Here is a small example (in VBScript) to show how to use the IPtoCountry object and translate an IP address to a country:
Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" ) ' Create instance of snmp mib browser objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" ) ' Load MIB file WScript.Echo "LoadMibFile, result: " & objSnmpMib.LastError If( objSnmpMib.LastError <> 0 ) Then WScript.Quit End If Set objSnmp = objSnmpMIB.Get("iso") ' Get first OID While(objSnmpMIB.LastError = 0 ) WScript.Echo "OID Name: " & objSnmp.Name & "; Full-path: " & objSnmp.Path WScript.Echo " Description: " & objSnmp.Description WScript.Echo " Access: " & objSnmp.Access WScript.Echo " Status: " & objSnmp.Status Set objSnmp = objSnmpMIB.GetNext() ' Get next OID WEnd
| Property | Type | In/Out | Mand/Opt | Description |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| Host | String | In/Out | yes | Host or IP address to be translated to a country |
| CountryCode | String | Out | n/a | Two-character country code (ISO 3166) associated with the given host or IP address |
| CountryCodeEx | String | Out | n/a | Three-character country code (ISO 3166) associated with the given host or IP address |
| CountryName | String | Out | n/a | Country name associated with the given host or IP address |
| LastError | Number | Out | n/a | Result of the Query function |
| LogFile | String | In/Out | O | Log file; use it for troubleshooting purposes |
| Function | Description |
| Clear | Reset all properties to the default values |
| Query | Translate an IP address (or host name) to a country |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Activate Software |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object
WScript.Echo "Version: " & objIPC.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object
WScript.Echo "Build: " & objIPC.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object
WScript.Echo "ExpirationDate: " & objIPC.ExpirationDate
Type:
Number
Description:
Host name or IP address to be translated. The Query function translates this host/IP address to a country.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object objIPC.Host = "www.activexperts.com" ' Host name (or IP address) that you want to resolve objIPC.Query() ' Translate host/IP to country WScript.Echo "Query, result: " & objIPC.LastError ' Result of Query; 0 means: success If objIPC.LastError <> 0 Then WScript.Quit End If WScript.Echo "Country (2 chars):" & objIPC.CountryCode ' Two-character ISO 3166 country code WScript.Echo "Country (3 chars):" & objIPC.CountryCodeEx ' Three-character ISO 3166 country code WScript.Echo "Country (full):" & objIPC.CountryName ' Full countryname
Type:
String
Description:
Country associates with the given host or IP address. You need call Query to translate the host/IP address to a country. There are three different notations for a country; there's a property for each:
For a list of possible country codes and country names, click here.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object objIPC.Host = "www.activexperts.com" ' Host name (or IP address) that you want to resolve objIPC.Query() ' Translate host/IP to country WScript.Echo "Query, result: " & objIPC.LastError ' Result of Query; 0 means: success If objIPC.LastError <> 0 Then WScript.Quit End If WScript.Echo "Country (2 chars):" & objIPC.CountryCode ' Two-character ISO 3166 country code WScript.Echo "Country (3 chars):" & objIPC.CountryCodeEx ' Three-character ISO 3166 country code WScript.Echo "Country (full):" & objIPC.CountryName ' Full countryname
Type:
Number
Description:
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object
...
objIPC.Query()
WScript.Echo "LastError: " & objIPC.LastError
Type:
String
Description:
For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object
objIPC.LogFile = "c:\file.log"
...
objIPC.Query()
WScript.Echo "LastError: " & objIPC.LastError
Description:
Reset all properties to their initial values. Use this function when you make consecutive calls to the Query function.
Parameters:
Return value:
Always 0.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object ... objIPC.Query() objIPC.Clear() ' Clear all properties objIPC.Query()
Description:
Translate an IP address (or host name) to a country.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object objIPC.Host = "www.activexperts.com" ' Host name (or IP address) that you want to resolve objIPC.Query() ' Translate host/IP to country WScript.Echo "Query, result: " & objIPC.LastError ' Result of Query; 0 means: success If objIPC.LastError <> 0 Then WScript.Quit End If WScript.Echo "Country (2 chars):" & objIPC.CountryCode ' Two-character ISO 3166 country code WScript.Echo "Country (3 chars):" & objIPC.CountryCodeEx ' Three-character ISO 3166 country code WScript.Echo "Country (full):" & objIPC.CountryName ' Full countryname ...
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) objIPC.Host = "www.activexperts.com" objIPC.Query() ' Translate host/IP to country WScript.Echo "Query, result: " & objIPC.LastError & _ ' Error code objIPC.GetErrorDescription( objIPC.LastError ) ' Error Description
Description:
This function can be used in your script anywhere you want. Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object ... objIPC.Sleep 500
Description:
This function will activate the ActiveSocket product. A valid registrationcode is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" ) ' Create IPtoCountry object objIPC.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started
The Msn object is an instant messaging client object. It allows you to connect to Microsoft's Live Messenger Service and send a basic message to one or more MSN recipients. It provides basic chat features only, i.e. a subset of the features provided by Windows Live Messenger (formerly known as MSN Messenger) which is available for most Windows operating systems. The Msn object doesn't provide enhanced features like emoticons and file transfers.
The features provided by the ActiveSocket Msn object:
Here is a small example (in VBScript) to show how to use the Msn object to send an instant message to a remote MSN recipient:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.LogFile = "C:\MSNLog.txt" ' Set Log File (optional) objMsn.MsnAccount = "mymeself@activexperts.com" ' Set MSN Account objMsn.MsnPassword = "topsecret" ' Set MSN Password objMsn.Message = "Hello World !!!!" ' Set MSN Message objMsn.AddRecipient "mycollegue1@activexperts.com" ' Add recipient(s) objMsn.AddRecipient "mycollegue2@activexperts.com" objMsn.Send ' Send the message WScript.Echo "Result : " & objMsn.LastError ' Display the result
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version of ActiveSocket |
| Build | String | Out | n/a | Build of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| Server | String | In/Out | M | The MSN server you want to connect to |
| ServerPort | Number | In/Out | M | The MSN server IP port number |
| MsnAccount | String | In/Out | M | The MSN account used to logon to the MSN server |
| MsnPassword | String | In/Out | M | The MSN password used to logon to the MSN server |
| MsnDisplayName | String | In/Out | O | The MSN display name used when logged on to the MSN server |
| Message | String | In/Out | M | The MSN message to send to the remote MSN recipient(s) |
| LastError | Number | Out | n/a | Result of last used function |
| LogFile | String | In/Out | O | Log file; use it for troubleshooting purposes |
| Function | Description |
| Clear | Reset all properties to the default values |
| AddRecipient | Add an MSN recipient |
| Send | Send the MSN message to the remote MSN recipient(s) |
| GetErrorDescription | Get the description of the given error |
| Activate | Activate Software |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object WScript.Echo "Version: " & objMsn.Version ' Show version information
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object WScript.Echo "Build: " & objMsn.Build ' Show build information
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object WScript.Echo "ExpirationDate: " & objMsn.ExpirationDate ' Show expiration date
Type:
String
Description:
The MSN server you want to connect to. Default value: messenger.hotmail.com
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.Server = "messenger2.hotmail.com" ' Use messenger2.hotmail.com objMsn.MsnAccount = "mymeself@activexperts.com" objMsn.MsnPassword = "topsecret" objMsn.Message = "Hello World !!!!" objMsn.AddRecipient "mycollegue1@activexperts.com" objMsn.Send ' Send the message
Type:
Number
Description:
IP port of the MSN server you want to connect to. Default value: 1863.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.Server = "messenger2.hotmail.com" ' Use messenger2.hotmail.com objMsn.ServerPort = 8063 ' Use port 8063 objMsn.MsnAccount = "mymeself@activexperts.com" objMsn.MsnPassword = "topsecret" objMsn.Message = "Hello World !!!!" objMsn.AddRecipient "mycollegue1@activexperts.com" objMsn.Send ' Send the message
Type:
String
Description:
The MSN account used to logon to the MSN server.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.MsnAccount = "mymeself@activexperts.com" ' Set MSN Account objMsn.MsnPassword = "topsecret" ' Set MSN Password objMsn.Message = "Hello World !!!!" objMsn.AddRecipient "mycollegue1@activexperts.com" objMsn.Send ' Send the message
Type:
String
Description:
The MSN password used to logon to the MSN server.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.MsnAccount = "mymeself@activexperts.com" ' Set MSN Account objMsn.MsnPassword = "topsecret" ' Set MSN Password objMsn.Message = "Hello World !!!!" objMsn.AddRecipient "mycollegue1@activexperts.com" objMsn.Send ' Send the message
Type:
String
Description:
The friendly name that will be shown to the remote MSN users. If omitted, the MSN Account is displayed.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.MsnAccount = "mymeself@activexperts.com" objMsn.MsnPassword = "topsecret" objMsn.MsnDisplayName = "Me Myself" ' Set MSN Display Name objMsn.Message = "Hello World !!!!" objMsn.AddRecipient "mycollegue1@activexperts.com" objMsn.Send ' Send the message
Type:
String
Description:
The Message text that to send to the remote recipients. The maximum length of a message is 1664 characters.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.MsnAccount = "mymeself@activexperts.com" objMsn.MsnPassword = "topsecret" objMsn.MsnDisplayName = "Me Myself" objMsn.Message = "Hello World !!!!" ' Set Message text objMsn.AddRecipient "mycollegue1@activexperts.com" objMsn.Send ' Send the message
Type:
Number
Description:
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object ... objMsn.Send ' Send the message WScript.Echo objMsn.LastError ' Display the result of the Send function
Type:
String
Description:
For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objLogFile = "c:\msn.log" ' Set log file ... objMsn.Send ' Send the message WScript.Echo objMsn.LastError ' Display the result of the Send function
Description:
Reset all properties to their initial values. Use this function when you make consecutive calls to the Send function.
Parameters:
Return value:
Always 0.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object ... objMsn.Send() objMsn.Clear() ' Clear all properties objMsn.Send()
Description:
Add an MSN recipient. You can add multiple recipients, i.e. call the AddRecipient function multiple times.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.Server = "messenger2.hotmail.com" objMsn.MsnAccount = "mymeself@activexperts.com" objMsn.MsnPassword = "topsecret" objMsn.Message = "Hello World !!!!" objMsn.AddRecipient "mycollegue1@activexperts.com" ' Add recipient(s) objMsn.AddRecipient "mycollegue2@activexperts.com" objMsn.Send ' Send the message WScript.Echo "Result : " & objMsn.LastError ' Display the result
Description:
Send the MSN message to the remote MSN recipient(s).
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.Server = "messenger2.hotmail.com" objMsn.MsnAccount = "mymeself@activexperts.com" objMsn.MsnPassword = "topsecret" objMsn.Message = "Hello World !!!!" objMsn.AddRecipient "mycollegue1@activexperts.com" objMsn.Send ' Send the message WScript.Echo "Result : " & objMsn.LastError
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object ... objMsn.Send ' Send the message WScript.Echo "Result : " & objMsn.LastError & " (" & objMsn.GetErrorDescription ( objMsn.LastError ) & ")"
Description:
This function will activate the ActiveSocket product. A valid registrationcode is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objMsn = CreateObject( "ActiveXperts.Msn" ) ' Create Msn object objMsn.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started
The Network Time Protocol (NTP) has been developed to address the issue of providing accurate and synchronized time across the Internet. The protocol itself has been in development since 1985 and has therefore reached a fairly mature status. The latest stable version of NTP is version 3 and described in RFC-1305 the latest testing version is NTP version 4.
The Network Time Protocol aims to synchronize a systems clock to Coordinated Universal Time (UTC). UTC is a development of Greenwich Mean Time (GMT). GMT is based on the rotation of the earth while UTC is based on the standard length of a second determined from quantum phenomena, but both use the Greenwich time zone as the zero offset.
NTP uses a augmented hierarchical client-server topology. A small number of servers distribute time to a larger number of clients which can simultaneously act as servers to further clients. The top level clients are referred to as stratum 1 servers and their clients are termed as being at stratum 2. Clients of a stratum 2 server are at stratum 3 and so on. The stratum 1 servers are synchronized to radio clocks which receive time signals from national time standards such as the MSF signal provided by the NPL broadcast from Rugby or the GPS time signal provided by the Global Positioning System. The radio clocks themselves are termed stratum 0 servers.
The ActiveSocket Ntp object enables you to add Ntp functionality to your program. Here is a small example (in VBScript) to show how to use the Ntp object: The following sample (in VBScript) runs the '/bin/ls' command on host '192.168.1.10', and will timeout when the script takes more than 5000 milliseconds:
objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create a new Ntp instance objNtp.GetTime "mytimeserver.domain.dom" ' Retrieve time from this time server If( objNtp.LastError = 0 ) Then WScript.Echo "Time retrieved successfully, the results are:" WScript.Echo "Year : " & objNtp.Year WScript.Echo "Month : " & objNtp.Month WScript.Echo "Day : " & objNtp.Day WScript.Echo "Hour : " & objNtp.Hour WScript.Echo "Minute : " & objNtp.Minute WScript.Echo "Second : " & objNtp.Second End If
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version number of ActiveSocket |
| Build | String | Out | n/a | Display build information of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| LastError | Number | Out | n/a | Result of the last called function |
| Year | Number | Out | n/a | The year, as provided by the NTP server |
| Month | Number | Out | n/a | The month, as provided by the NTP server |
| Day | Number | Out | n/a | The day, as provided by the NTP server |
| Hour | Number | Out | n/a | The hour, as provided by the NTP server |
| Minute | Number | Out | n/a | The minute, as provided by the NTP server |
| Second | Number | Out | n/a | The second, as provided by the NTP server |
| LocalOffsetSeconds | Number | Out | n/a | The offset (in seconds) between the local computer and the Network Time Server |
| Function | Description |
| Clear | Reset all properties to the default values |
| GetTime | Query the NTP server to retrieve date and time |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Activate Software |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create Ntp object
WScript.Echo "Version: " & objNtp.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create Ntp object
WScript.Echo "Build: " & objNtp.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create Ntp object
WScript.Echo "ExpirationDate: " & objNtp.ExpirationDate
Type:
Number
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create a new Ntp instance objNtp.GetTime "timeserver01.domain.dom" ' Retrieve time WScript.Echo "LastError: " & objNtp.LastError
Type:
Number
Description:
After a successful call to the GetTime function, the 'Year', 'Month', 'Day', 'Hour', 'Minute' and 'Second' properties are assigned with the time information that was retrieved from the Network Time Server. The properties are read-only; you cannot assign a value to it.
Example:
objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create a new Ntp instance objNtp.GetTime( "timeserver.domain.dom" ) ' Retrieve time if( objNtp.LastError = 0 ) Then WScript.Echo "Year : " & objNtp.Year WScript.Echo "Month : " & objNtp.Month WScript.Echo "Day : " & objNtp.Day WScript.Echo "Hour : " & objNtp.Hour WScript.Echo "Minute : " & objNtp.Minute WScript.Echo "Second : " & objNtp.Second End If
Type:
Number
Description:
After a successful call to the GetTime function, the 'LocalOffsetSeconds' holds the offset (in seconds) between the NTP server time and the local computer time. Use this value to check if your local computer time is in sync with the NTP server's time. The property is read-only; you cannot assign a value to it.
Example:
objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create a new Ntp instance objNtp.GetTime( "timeserver.domain.dom" ) ' Retrieve time If( objNtp.LastError = 0 ) Then WScript.Echo "Time offset : " & objNtp.LocalOffsetSeconds & " seconds" End If
Description:
Resets all properties to the initial values. Use this function when you make consecutive calls to the GetTime function. It sets LastError and Year, Month, Day, Hour, Minute and Second to 0.
Parameters:
Return value:
Always 0.
Example:
objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create a new Ntp instance objNtp.GetTime( "timeserver.domain.dom" ) ' Retrieve time ... objNtp.Clear() objNtp.GetTime( "timeserver02.domain.dom" ) ... objNtp.Clear() objNtp.GetTime( "timeserver03.domain.dom" ) ...
Description:
Query the network time server and retrieve its date and time.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create a new Ntp instance objNtp.GetTime( "timeserver.domain.dom" ) ' Retrieve time If( objNtp.LastError = 0 ) Then WScript.Echo "Year : " & objNtp.Year WScript.Echo "Month : " & objNtp.Month WScript.Echo "Day : " & objNtp.Day WScript.Echo "Hour : " & objNtp.Hour WScript.Echo "Minute : " & objNtp.Minute WScript.Echo "Second : " & objNtp.Second End If
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objNtp = CreateObject("ActiveXperts.Ntp") ' Create a new Ntp instance
objNtp.GetTime( "invalidtimeserver.com" ) ' Retrieve time
WScript.Echo "Error description: " & objNtp.GetErrorDescription( objNtp.LastError )
Description:
This function can be used in your script anywhere you want. Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0.
Example:
Set objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create Ntp object Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object ... objNtp.Sleep 500
Description:
This function activates the ActiveSocket product. A valid registration code is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objNtp = CreateObject( "ActiveXperts.Ntp" ) ' Create Ntp object objNtp.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started
RADIUS (Remote Authentication Dial In User Service) is a networking protocol that provides centralized authentication and authorization management for computers to connect and use a network service. It was originally developed by Livingston Enterprises in 1991 as an access server authentication and accounting protocol and later brought into the IETF standards where it is described in RCF 2865 and RCF 2866.
RADIUS is a client/server protocol that uses UDP as a transport. A RADIUS server is usually a background process running on a UNIX or Windows NT server. The RADIUS component in activesocket currently only supports authenticating users. This means that the activesocket RADIUS implementation can be used to check against a RADIUS server whether or not a user has access to a network.
The following sample (in VBScript) tests if the user 'Test' has access to a network, and will timeout when the script takes more than 5000 milliseconds:
Set objRadius = CreateObject("ActiveXperts.Radius") ' Create a RADIUS instance
objRadius.CheckAccess "192.168.1.10", "test", "password", "secret" ' Check if the test user is authorized
If objRadius.LastError <> 0 Then
WScript.Echo "Error: " & objRadius.LastError
WScript.Echo "Description " & objRadius.GetErrorDescription(objRadius.LastError)
WScript.Quit 1
End If
WScript.Echo "Ready."
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version number of ActiveSocket |
| Build | String | Out | n/a | Display build information of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| LastError | Number | Out | n/a | Result of the last called function |
| Timeout | Number | In/Out | O | Specifies the number of milliseconds until the command times out |
| Function | Description |
| Clear | Reset all properties to the default values |
| CheckAccess | Check if a user would be authorized |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Activate Software |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objRADIUS = CreateObject( "ActiveXperts.RADIUS" ) ' Create RADIUS object
WScript.Echo "Version: " & objRADIUS.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objRADIUS = CreateObject( "ActiveXperts.RADIUS" ) ' Create RADIUS object
WScript.Echo "Build: " & objRADIUS.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objRADIUS = CreateObject( "ActiveXperts.RADIUS" ) ' Create RADIUS object
WScript.Echo "ExpirationDate: " & objRADIUS.ExpirationDate
Type:
Number
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objRADIUS = CreateObject("ActiveXperts.RADIUS") ' Create an RADIUS instance
...
objRADIUS.CheckAccess "192.168.1.10", "test", "password", "secret"
WScript.Echo "LastError: " & objRADIUS.LastError
Type:
Number
Description:
Specifies the number of milliseconds before the command will time out.
Example:
Set objRADIUS = CreateObject("ActiveXperts.RADIUS") ' Create an RADIUS instance
objRADIUS.TimeOut = 6000 ' Timeout after 6000 milliseconds
objRADIUS.CheckAccess "192.168.1.10", "test", "password", "secret"
Description:
Reset all properties to the initial values. Use this function when you make consecutive calls to the Run function. It resets all properties
Parameters:
Return value:
Always 0.
Example:
Set objRADIUS = CreateObject("ActiveXperts.RADIUS") ' Create an RADIUS instance
...
objRADIUS.Timeout = 10000
objRADIUS.CheckAccess "192.168.1.10", "test", "password", "secret"
objRADIUS.Clear ' Resets properties
' Set new property values
...
objRADIUS.Timeout = 8000
objRADIUS.CheckAccess "192.168.1.10", "test", "password", "secret"
objRADIUS.Clear
...
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objRADIUS = CreateObject("ActiveXperts.RADIUS") ' Create an RADIUS instance
objRADIUS.CheckAccess "192.168.1.10", "test", "password", "secret"
WScript.Echo "Run: result = " & objRADIUS.LastError
Description:
This function activates the ActiveSocket product. A valid registration code is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objRADIUS = CreateObject( "ActiveXperts.RADIUS" ) ' Create RADIUS object objRADIUS.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started
Rsh executes a command on a host. The remote hosts must run the Rsh daemon.
An Rsh client utility is shipped with most operating systems these days.
This Rsh command line utility copies its standard input to the remote command, the standard output
of the remote command to its standard output, and the standard error of the remote command to its standard error.
Interrupt, quit and terminate signals are propagated to the remote command; rsh normally terminates when the remote command does.
The ActiveSocket Rsh object has the same functionality as the Rsh command-line utility, except that it has no user interface by itself: standard error and standard output are not copied to the console, but are copied to the corresponding object properties (StdErr and StdOut) instead.
The following sample (in VBScript) runs the '/bin/ls' command on host '192.168.1.10', and will timeout when the script takes more than 5000 milliseconds:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
objRsh.Host = "192.168.1.10" ' Hostname or IP address of remote UNIX/LINUX machine
objRsh.UserName = "root" ' Login as 'root'
objRsh.Password = "topsecret" ' Use a password to login
objRsh.Command = "/bin/ls" ' Command to execute
objRsh.ScriptTimeOut = 5000 ' Time-out (in milliseconds)
objRsh.Run ' Execute the command now
WScript.Echo "Run: result = " & objRsh.LastError
If objRsh.LastError <> 0 Then
WScript.Echo "Error " & objRsh.LastError
End If
' YES, command has completed
WScript.Echo "StdErr: " & objRsh.StdErr ' Print Standard Output
WScript.Echo "StdOut: " & objRsh.StdOut ' Print Standard Error
WScript.Echo "Ready."
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version number of ActiveSocket |
| Build | String | Out | n/a | Display build information of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| LastError | Number | Out | n/a | Result of the last called function |
| Command | String | In/Out | M | Specifies the command to run on the remote host |
| Host | String | In/Out | M | Specifies the host on which to run the command |
| UserName | String | In/Out | M | Specifies the user name to use on the remote host. If omitted, the logged on user name is used. |
| ScriptTimeOut | Number | In/Out | O | Specifies the number of milliseconds until the command times out |
| StdErr | String | Out | n/a | The Rsh 'Run' function copies its standard error to this property |
| StdOut | String | Out | n/a | The Rsh 'Run' function copies its standard output to this property |
| Function | Description |
| Clear | Reset all properties to the default values |
| Run | Run the command on the remote host |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Activate Software |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objRsh = CreateObject( "ActiveXperts.Rsh" ) ' Create Rsh object
WScript.Echo "Version: " & objRsh.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objRsh = CreateObject( "ActiveXperts.Rsh" ) ' Create Rsh object
WScript.Echo "Build: " & objRsh.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objRsh = CreateObject( "ActiveXperts.Rsh" ) ' Create Rsh object
WScript.Echo "ExpirationDate: " & objRsh.ExpirationDate
Type:
Number
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
...
objRsh.Run
WScript.Echo "LastError: " & objRsh.LastError
Type:
String
Description:
Specifies the command to run on the remote host.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
objRsh.Command = "/bin/ls"
objRsh.Host = "server01.domain.dom"
objRsh.Run
Type:
String
Description:
Specifies the user name to use on the remote host. If omitted, the logged on user name is used.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
objRsh.Host = "server01.domain.dom"
objRsh.Command = "/bin/ls"
objRsh.UserName = "mjohnson"
objRsh.Run
Type:
String
Description:
Specifies the host on which to run the command.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
objRsh.Host = "server01.domain.dom"
objRsh.Command = "/bin/ls"
objRsh.Run
Type:
Number
Description:
Specifies the number of milliseconds before the command will time out.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
objRsh.Host = "server01.domain.dom"
objRsh.Command = "/bin/ls"
objRsh.ScriptTimeOut = 6000 ' Timeout after 6000 milliseconds
objRsh.Run
Type:
String
Description:
Rsh connects to the host and executes the command. Rsh copies its standard error of the remote command to the 'StdErr' property.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
...
objRsh.Run
If( objRsh.LastError = 0 ) Then
WScript.Echo "StdErr: " & objRsh.StdErr
End
Type:
String
Description:
Rsh connects to the host and executes the command. Rsh copies its standard out of the remote command to the 'StdOut' property.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
objRsh.Run
If( objRsh.LastError = 0 ) Then
WScript.Echo "StdOut: " & objRsh.StdOut
End
Description:
Reset all properties to the initial values. Use this function when you make consecutive calls to the Run function. It resets all properties
Parameters:
Return value:
Always 0.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
...
objRsh.Run
objRsh.Clear ' Resets properties
' Set new property values
...
objRsh.Run
objRsh.Clear
...
Description:
Run the command on the remote host.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
objRsh.Host = "192.168.1.10"
objRsh.Command = "/bin/ls"
objRsh.Run
WScript.Echo "Run: result = " & objRsh.LastError
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objRsh = CreateObject("ActiveXperts.Rsh") ' Create an Rsh instance
objRsh.Host = "192.168.1.10"
objRsh.Command = "/bin/ls"
objRsh.Run
WScript.Echo "Run: result = " & objRsh.LastError
Description:
This function can be used in your script anywhere you want. Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0.
Example:
Set objRsh = CreateObject( "ActiveXperts.Rsh" ) ' Create Rsh object Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object ... objRsh.Sleep 500
Description:
This function activates the ActiveSocket product. A valid registration code is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objRsh = CreateObject( "ActiveXperts.Rsh" ) ' Create Rsh object objRsh.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started
Scp (Secure Copy Protocol) is a way to securely transfer files between two computers using the SSH (Secure SHell) protocol.
The Secure Copy Protocol is the secure analog of the old UNIX RCP command. It is implemented as a part of the SSH system, which means that an SCP client can be used to copy to any file or files to or from a host which has an SSH server running and which has the SCP service enabled.
An SCP client can only be used to copy files. To list the contents of a remote directory or to query for remote file information either SSH or SFTP would be required. In most applications the SCP protocol is considered to be superseded by the more advanced SFTP protocol. However, in some implementations copying a file using an SCP implementation can have a performance advantage.
The ActiveSocket SCP implementation is based on the PuTTY SCP implementation.
When connecting to a remote host there are two ways to authenticate: by using a password or by using a 'private key'. When using a password to authenticate it is required that the host private key is known to the system. If the hosts private key is unknown to the system or if it was changed since the last connection the Scp object will return an error. To connect anyway and store the host key in the registry for future connections the 'AcceptHostKey' property can be set.
NOTE:
The following sample (in VBScript) copies the 'Smalltoken.file to the 'demo' users home directory on 192.168.1.10 using a password:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
objScp.Host = "192.168.1.10" ' Hostname or IP address of remote UNIX/LINUX machine
objScp.UserName = "demo" ' Login as 'demo'
objScp.Password = "topsecret" ' Use a password to login
objScp.CopyToRemote "Smalltoken.file", "." ' Copy the file to the remote location
WScript.Echo "Copy: result = " & objScp.LastError
If objScp.LastError <> 0 Then
WScript.Echo "Error: " & objScp.LastError
If objScp.ProtocolError <> "" Then
WScript.Echo "Protocol error: " & objScp.ProtocolError
End If
End If
' YES, command has completed
WScript.Echo "Ready."
The following sample (in VBScript) copies the 'Smalltoken.file to the 'demo' users home directory on 192.168.1.10 using a private key file:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
objScp.Host = "192.168.1.10" ' Hostname or IP address of remote UNIX/LINUX machine
objScp.UserName = "demo" ' Login as 'demo'
objScp.PrivateKeyFile = "c:\files\privkey.ppk" ' Use a private key file to login
objScp.CopyToRemote "Smalltoken.file", "." ' Copy the file to the remote location
WScript.Echo "Copy: result = " & objScp.LastError
If objScp.LastError <> 0 Then
WScript.Echo "Error: " & objScp.LastError
If objScp.ProtocolError <> "" Then
WScript.Echo "Protocol error: " & objScp.ProtocolError
End If
End If
' YES, command has completed
WScript.Echo "Ready."
| Property | Type | In/Out | Mand/Opt | Description | |
| Version | String | Out | n/a | Version number of ActiveSocket | |
| Build | String | Out | n/a | Display build information of ActiveSocket | |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket | |
| LastError | Number | Out | n/a | Result of the last called function | |
| ProtocolError | String | Out | n/a | If the last called function triggered a protocol error. This property will contain more information. | |
| Host | String | In/Out | M | Specifies the host to which or from which should be copied | |
| Port | Number | In/Out | O | TCP port number to identify a (remote) SSH/SCP daemon. Default: 22 | |
| UserName | String | In/Out | M | Specifies the user name to use on the remote host | |
| Password | String | In/Out | O | Specifies the password to use on the remote host. If this property is left blank the 'PrivateKeyFile' property will be used to authenticate. | |
| PrivateKeyFile | String | In/Out | O | Specifies the private key file to logon to the remote host. If this property is left blank the 'Password' property will be used to authenticate. | |
| Recursive | Boolean | In/Out | O | Specifies whether to recursively copy directories | |
| Compression | Boolean | In/Out | O | Specifies whether to use compression when transferring files | |
| AcceptHostKey | Boolean | In/Out | O | Specifies whether to accept an unknown or changed host key | |
| HostFingerprint | String | Out | n/a | The Scp 'CopyToRemote' and 'CopyToLocal' functions copy the host key fingerprint to this property | |
| LogFile | Boolean | In/Out | O | Log file; use it for troubleshooting purposes |
| Function | Description |
| Clear | Reset all properties to the default values |
| CopyToLocal | Copy the files to the local host |
| CopyToRemote | Copy the files to the remote host |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Activate Software |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objScp = CreateObject( "ActiveXperts.Scp" ) ' Create Scp object
WScript.Echo "Version: " & objScp.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objScp = CreateObject( "ActiveXperts.Scp" ) ' Create Scp object
WScript.Echo "Build: " & objScp.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objScp = CreateObject( "ActiveXperts.Scp" ) ' Create Scp object
WScript.Echo "ExpirationDate: " & objScp.ExpirationDate
Type:
Number
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.CopyToRemote "Smalltoken.file", "."
WScript.Echo "LastError: " & objScp.LastError
Type:
String
Description:
If the last called function triggered a protocol error. This property will contain more information. The protocol error string is usually triggered and formulated into an error description at the remote host.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.CopyToRemote "Smalltoken.file", "."
If objScp.LastError <> 0 Then
WScript.Echo "Error: " & objScp.LastError
If objScp.ProtocolError <> "" Then
WScript.Echo "Protocol error: " & objScp.ProtocolError
End If
End If
Type:
String
Description:
Specifies the host onto or from which the files will be copied.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
objScp.Host = "server01.domain.dom"
...
objScp.CopyToRemote "Smalltoken.file", "."
Type:
Number
Description:
TCP port number to identify a remote SSH/SCP daemon. If you don't specify the 'Port' property, port 22 (default SCP port) is used.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
objScp.Host = "server01.domain.dom"
objScp.Port = 8022 ' Use port 8022 instead of 22
...
objScp.CopyToRemote "Smalltoken.file", "."
Type:
String
Description:
Specifies the user name to use on the remote host. You must also specify either a Password or Private Key to logon to the machine.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
objScp.Host = "server01.domain.dom"
objScp.UserName = "mjohnson"
objScp.Password = "topsecret"
objScp.CopyToRemote "Smalltoken.file", "."
Type:
String
Description:
Specifies the password to use on the remote host. If you do not use a password, you must use a Private Key to logon to the machine.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
objScp.Host = "server01.domain.dom"
objScp.UserName = "mjohnson"
objScp.Password = "topsecret"
objScp.CopyToRemote "Smalltoken.file", "."
Type:
String
Description:
Specifies the private key file to use on the remote host. If you do not use a private key, you must use a Password to logon to the machine.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
objScp.Host = "server01.domain.dom"
objScp.UserName = "mjohnson"
objScp.PrivateKeyFile= "c:\keys\root.ppk"
objScp.CopyToRemote "Smalltoken.file", "."
Type:
Boolean
Description:
Specifies whether to recursively copy directories. To copy a directory and its subdirectories the recursive property should be enabled.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.Recursive = true
objScp.CopyToRemote "Smalltoken.file", "."
Type:
Boolean
Description:
Specifies whether to use compression when copying files to the remote location. This will enable faster file transfer rates at the cost of a higher load on the server/client side.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.Compression = true
objScp.CopyToRemote "Smalltoken.file", "."
Type:
Boolean
Description:
Specifies whether to accept an unknown or changed host key and add it to the registry. Leaving this property set to true when connecting to unknown or untrusted hosts poses a security risk.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.AcceptHostKey = true
objScp.CopyToRemote "Smalltoken.file", "."
Type:
String
Description:
The Scp 'CopyToRemote' and 'CopyToLocal' functions copy the host key fingerprint to this property
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.CopyToRemote "Smalltoken.file", "."
WScript.Echo "Host key fingerprint: " & objScp.HostFingerprint
Type:
String
Description:
For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.LogFile = "Log.txt"
objScp.CopyToRemote "Smalltoken.file", "."
Description:
Reset all properties to the initial values.
Parameters:
Return value:
Always 0.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.CopyToRemote "Smalltoken.file", "."
objScp.Clear ' Resets properties
' Set new property values
...
objScp.CopyToRemote "Smalltoken.file", "."
objScp.Clear
...
Description:
Copy a file or directory from the remote host specified in the 'Host' property to the local host.
Parameters:
Return value:
Always 0.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.CopyToLocal "Smalltoken.file", "C:\test"
Description:
Copy a file or directory from the local to the remote host specified in the 'Host' property.
Parameters:
Return value:
Always 0.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
...
objScp.CopyToRemote "Smalltoken.file", "/var/www/upload"
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objScp = CreateObject("ActiveXperts.Scp") ' Create an Scp instance
objScp.Host = "192.168.1.10"
objScp.UserName = "mjohnson"
objScp.Password = "topsecret"
objScp.CopyToRemote "Smalltoken.file", "."
WScript.Echo "Error description: " & objScp.GetErrorDescription( objScp.LastError )
Description:
This function can be used in your script anywhere you want. Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0.
Example:
Set objScp = CreateObject( "ActiveXperts.Scp" ) ' Create Scp object
...
objScp.Sleep 500
Description:
This function activates the ActiveSocket product. A valid registration code is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objScp = CreateObject( "ActiveXperts.Scp" ) ' Create Scp object objScp.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started
SFTP (Secure File Transfer Protocol) allows secure network file transfer over an insecure network, such as the Internet.
The Secure File Transfer Protocol is an extension to the SSH version 2.0 protocol. Most SSH server implementations will also allow for SFTP logins. SFTP is the secure successor to SFTP.
The ActiveSocket SFTP implementation is based on the PuTTY implementation. With the ActiveSocket SFtp object, you can login onto a remote machine running the SSH-2 daemon and has the SFTP service enabled.
There are two ways to authenticate: by using a password or by using a 'private key'. When using a password to authenticate it is required that the host private key is known to the system. If the hosts private key is unknown to the system or if it was changed since the last connection the Sftp object will return an error. To connect anyway and store the host key in the registry for future connections the 'AcceptHostKey' property can be set.
NOTE:
The following sample (in VBScript) changes to a 'test' directory, lists the directory and gets the 'Smalltoken.file' file on '192.168.1.10' by logging in using a password:
' Helper function to expand a string variable to a specified length Function Pad(ByRef Text, ByVal Length) Pad = Left(Text & Space(Length), Length) End Function ' Helper function to test and find the error description and exit Function test_lasterror() If objSFtp.LastError <> 0 Then WScript.Echo "Error " & objSFtp.LastError If objSFtp.ProtocolError <> "" Then WScript.Echo "Protocol error: " & objSFtp.ProtocolError WScript.Quit 1 End If End If End Function ' Connect to the host Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance objSFtp.Host = "192.168.1.10" ' Hostname or IP address of remote UNIX/LINUX machine objSFtp.UserName = "demo" ' Login as 'demo' objSFtp.Password = "topsecret" ' Use a password to login WScript.Echo "Connect" objSFtp.Connect ' Connect to the SFTP server test_lasterror ' Change directory objSFtp.ChangeDir "test" test_lasterror ' List directory contents Set f = objSFtp.FindFirstFile(".") test_lasterror While objSFtp.LastError = 0 str = pad(f.name, 30) & pad(f.SizeKb & "KB", 10) & f.Date WScript.Echo str Set f = objSFtp.FindNextFile WEnd ' Get smalltoken file objSFtp.GetFile "Smalltoken.file", "." test_lasterror objSFtp.Disconnect ' YES, command has completed WScript.Echo "Ready."
| Property | Type | In/Out | Mand/Opt | Description |
| Name | String | Out | n/a | Filename |
| IsDirectory | Boolean | Out | n/a | Is the file a directory (True) or a file (False) |
| SizeBytes | Number | Out | n/a | Size of file (in bytes) |
| SizeBytesHigh | Number | Out | n/a | High part of he size of the file |
| SizeKB | Number | Out | n/a | Size of file (in kilobytes) |
| SizeMB | Number | Out | n/a | Size of file (in megabytes) |
| DateSeconds | Number | Out | n/a | Last modification date of the file (in seconds after 1/1/1970) |
| Date | String | Out | n/a | Last modification date of the file (as a friendly string) |
| Function | Description |
| None | No functions defined for the FtpFile object |
Type:
String
Description:
File name.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance ... objSFtp.Connect ' Connect to the SFTP server ... Set objSFtpFile = objSFtp.FindFirstFile(".") ' Get first file in the directory If( objSFtp.LastError = 0 ) Then WScript.Echo "Name : " & objSFtpFile.Name WScript.Echo "IsDirectory : " & objSFtpFile.IsDirectory WScript.Echo "Size (in bytes) : " & objSFtpFile.SizeBytes WScript.Echo "DateSeconds : " & objSFtpFile.DateSeconds WScript.Echo "Date : " & objSFtpFile.Date ' Display last modified date/time as a friendly string End If ... objSFtp.Disconnect ' Disconnect
Type:
Boolean
Description:
True indicates a directory, False indicates a file.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance ... objSFtp.Connect ' Connect to the SFTP server ... Set objSFtpFile = objSFtp.FindFirstFile(".") ' Get first file in the directory If( objSFtp.LastError = 0 ) Then WScript.Echo "Name : " & objSFtpFile.Name WScript.Echo "IsDirectory : " & objSFtpFile.IsDirectory WScript.Echo "Size (in bytes) : " & objSFtpFile.SizeBytes WScript.Echo "DateSeconds : " & objSFtpFile.DateSeconds WScript.Echo "Date : " & objSFtpFile.Date ' Display last modified date/time as a friendly string End If ... objSFtp.Disconnect ' Disconnect
Type:
Number
Description:
Size (in bytes) of the file. This field is actually the lower part of a 64Bit file size. The high part is located in the SizeBytesHigh property. Using only this property will be sufficient if files are not bigger than 4GB.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance ... objSFtp.Connect ' Connect to the SFTP server ... Set objSFtpFile = objSFtp.FindFirstFile(".") ' Get first file in the directory If( objSFtp.LastError = 0 ) Then WScript.Echo "Name : " & objSFtpFile.Name WScript.Echo "IsDirectory : " & objSFtpFile.IsDirectory ' Calculate the size of the file. WScript.Echo "Size (in bytes) : " & (objSFtpFile.SizeBytesHigh * (2^32) + bjFtpFile.SizeBytes) WScript.Echo "DateSeconds : " & objSFtpFile.DateSeconds WScript.Echo "Date : " & objSFtpFile.Date ' Display last modified date/time as a friendly string End If ... objSFtp.Disconnect ' Disconnect
Type:
Number
Description:
The high 32bit part of he size of the file. The lower part is located in the SizeBytes property. If the filesize is smaller than 4GB this property will be 0.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance ... objSFtp.Connect ' Connect to the SFTP server ... Set objSFtpFile = objSFtp.FindFirstFile(".") ' Get first file in the directory If( objSFtp.LastError = 0 ) Then WScript.Echo "Name : " & objSFtpFile.Name WScript.Echo "IsDirectory : " & objSFtpFile.IsDirectory ' Calculate the size of the file. WScript.Echo "Size (in bytes) : " & (objSFtpFile.SizeBytesHigh * (2^32) + bjFtpFile.SizeBytes) WScript.Echo "DateSeconds : " & objSFtpFile.DateSeconds WScript.Echo "Date : " & objSFtpFile.Date ' Display last modified date/time as a friendly string End If ... objSFtp.Disconnect ' Disconnect
Type:
Number
Description:
Contains the size in KB of the file when the file size is smaller than 4TB (4 Terabyte; 4 * 2^40 Bytes).
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance ... objSFtp.Connect ' Connect to the SFTP server ... Set objSFtpFile = objSFtp.FindFirstFile(".") ' Get first file in the directory If( objSFtp.LastError = 0 ) Then WScript.Echo "Name : " & objSFtpFile.Name WScript.Echo "IsDirectory : " & objSFtpFile.IsDirectory WScript.Echo "Size (in KB) : " & objSFtpFile.SizeKB WScript.Echo "DateSeconds : " & objSFtpFile.DateSeconds WScript.Echo "Date : " & objSFtpFile.Date ' Display last modified date/time as a friendly string End If ... objSFtp.Disconnect ' Disconnect
Type:
Number
Description:
Contains the size in MB of the file when the file size is smaller than 4PB (4 Petabyte; 4 * 2^50 Bytes).
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance ... objSFtp.Connect ' Connect to the SFTP server ... Set objSFtpFile = objSFtp.FindFirstFile(".") ' Get first file in the directory If( objSFtp.LastError = 0 ) Then WScript.Echo "Name : " & objSFtpFile.Name WScript.Echo "IsDirectory : " & objSFtpFile.IsDirectory WScript.Echo "Size (in MB) : " & objSFtpFile.SizeMB WScript.Echo "DateSeconds : " & objSFtpFile.DateSeconds WScript.Echo "Date : " & objSFtpFile.Date ' Display last modified date/time as a friendly string End If ... objSFtp.Disconnect ' Disconnect
Type:
Number
Description:
last modified date and time of the file, in seconds after 1/1/1970.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance ... objSFtp.Connect ' Connect to the SFTP server ... Set objSFtpFile = objSFtp.FindFirstFile(".") ' Get first file in the directory If( objSFtp.LastError = 0 ) Then WScript.Echo "Name : " & objSFtpFile.Name WScript.Echo "IsDirectory : " & objSFtpFile.IsDirectory WScript.Echo "Size (in bytes) : " & objSFtpFile.SizeBytes WScript.Echo "DateSeconds : " & objSFtpFile.DateSeconds WScript.Echo "Date : " & objSFtpFile.Date ' Display last modified date/time as a friendly string End If ... objSFtp.Disconnect ' Disconnect
Type:
String
Description:
last modified date and time of the file, as a friendly string.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance ... objSFtp.Connect ' Connect to the SFTP server ... Set objSFtpFile = objSFtp.FindFirstFile(".") ' Get first file in the directory If( objSFtp.LastError = 0 ) Then WScript.Echo "Name : " & objSFtpFile.Name WScript.Echo "IsDirectory : " & objSFtpFile.IsDirectory WScript.Echo "Size (in bytes) : " & objSFtpFile.SizeBytes WScript.Echo "DateSeconds : " & objSFtpFile.DateSeconds WScript.Echo "Date : " & objSFtpFile.Date ' Display last modified date/time as a friendly string End If ... objSFtp.Disconnect ' Disconnect
| Property | Type | In/Out | Mand/Opt | Description | |
| Version | String | Out | n/a | Version number of ActiveSocket | |
| Build | String | Out | n/a | Display build information of ActiveSocket | |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket | |
| LastError | Number | Out | n/a | Result of the last called function | |
| ProtocolError | String | Out | n/a | If the last called function triggered a protocol error. This property will contain more information. | |
| Host | String | In/Out | M | Specifies the host to connect to | |
| Port | Number | In/Out | O | TCP port number to identify a (remote) SFTP daemon. Default: 22 | |
| UserName | String | In/Out | M | Specifies the user name to use on the remote host | |
| Password | String | In/Out | O | Specifies the password to use on the remote host. If this property is left blank the 'PrivateKeyFile' property will be used to authenticate. | |
| PrivateKeyFile | String | In/Out | O | Specifies the private key file to logon to the remote host. If this property is left blank the 'password' property will be used to authenticate. | |
| AcceptHostKey | Boolean | In/Out | O | Specifies whether to accept an unknown or changed host key | |
| HostFingerprint | String | Out | n/a | The SFtp 'Connect' function copies the host key fingerprint to this property | |
| Compression | Boolean | In/Out | n/a | Specifies whether compression should be used while transferring files | |
| LogFile | String | In/Out | n/a | Log file; use it for troubleshooting purposes |
| Function | Description |
| Clear | Reset all properties to their default values |
| Connect | Connect to a remote SFTP server |
| Disconnect | Close the connection |
| GetCurrentDir | Retrieve the current directory |
| ChangeDir | Change directory |
| CreateDir | Create directory |
| RenameDir | Rename directory |
| DeleteDir | Delete directory |
| FindFile | Find a file in the current directory |
| FindFirstFile | Find first file in the search pattern / directory |
| FindNextFile | Find next file in the current directory |
| RenameFile | Rename a file in the current directory |
| DeleteFile | Delete a file in the current directory |
| GetFile | Download (get) a file from the current directory |
| PutFile | Upload (put) a file to the current directory |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Suspends the execution of the object for at least the specified interval |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create SFtp object
WScript.Echo "Version: " & objSFtp.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create SFtp object
WScript.Echo "Build: " & objSFtp.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create SFtp object
WScript.Echo "ExpirationDate: " & objSFtp.ExpirationDate
Type:
Number
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
...
objSFtp.Connect
WScript.Echo "LastError: " & objSFtp.LastError
Type:
String
Description:
If the last called function triggered a protocol error. This property will contain more information. The protocol error string is usually triggered and formulated into an error description at the remote host.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
...
objSFtp.Connect
WScript.Echo "ProtocolError: " & objSFtp.ProtocolError
Type:
String
Description:
Specifies the host on which to run the command.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
objSFtp.Host = "server01.domain.dom"
...
objSFtp.Connect
Type:
Number
Description:
TCP port number to identify a remote SSH daemon. If you don't specify the 'Port' property, port 22 (default SSH port) is used.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
objSFtp.Host = "server01.domain.dom"
objSFtp.Port = 8022 ' Use port 8022 instead of 22
...
objSFtp.Connect
Type:
String
Description:
Specifies the user name to use on the remote host. You must also specify either a Password or Private Key to logon to the machine.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
objSFtp.Host = "server01.domain.dom"
objSFtp.UserName = "mjohnson"
objSFtp.Password = "topsecret"
objSFtp.Connect
Type:
String
Description:
Specifies the password to use on the remote host. If you do not use a password, you must use a Private Key to logon to the machine.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
objSFtp.Host = "server01.domain.dom"
objSFtp.UserName = "mjohnson"
objSFtp.Password = "topsecret"
objSFtp.Connect
Type:
String
Description:
Specifies the private key file to use on the remote host. If you do not use a private key, you must use a Password to logon to the machine.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
objSFtp.Host = "server01.domain.dom"
objSFtp.UserName = "mjohnson"
objSFtp.PrivateKeyFile= "c:\keys\root.ppk"
objSFtp.Connect
Type:
Boolean
Description:
Specifies whether to accept an unknown or changed host key and add it to the registry. Leaving this property set to true when connecting to unknown or untrusted hosts poses a security risk.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
...
objSFtp.AcceptHostKey = true
objSFtp.Connect
Type:
String
Description:
The SFtp 'Connect' function copies the host key fingerprint to this property
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
...
objSFtp.Connect
WScript.Echo "Host key fingerprint: " & objSFtp.HostFingerprint
Type:
Boolean
Description:
Specifies whether to use compression when copying files to the remote location. This will enable faster file transfer rates at the cost of a higher load on the server/client side.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
...
objSFtp.Compression = true
objSFtp.Connect
Type:
String
Description:
For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.
Example:
Set objSFtp = CreateObject("ActiveXperts.SFtp") ' Create an SFtp instance
...
objSFtp.LogFile = "Log.txt"
objSFtp.Connect
Description:
Resets all properties to the initial, default values.
Parameters:
Return value:
Always 0.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 ... objSFtp.Disconnect ' Disconnect objSFtp.Clear ' Clear properties before connecting to another SFTP server objSFtp.Host = "SFtp2" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp2
Description:
Call this function to connect to a remote SFTP server.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.ChangeDir( "/pictures" ) ... objSFtp.Disconnect End If
Description:
Call this function to close a connnection that was established using the Connect function.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.Disconnect ' Close the session End If
Description:
The directory string. If the function fails, an empty string is returned and the LastError property is set to a non-zero value indicating the reason for failing.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... strCurrentDir = objSFtp.GetCurrentDir() ' Retrieve current directory If( objSFtp.LastError = 0 ) Then WScript.Echo "Current Directory: " & strCurrentDir End If objSFtp.Disconnect ' Close the session End If
Description:
Change the current directory on the remote SFTP server. You can use a fully qualified directory name, or a plain directory name.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.ChangeDir( "/pictures" ) ' Change directory to: /pictures objSFtp.ChangeDir( "family" ) ' Change directory to: /pictures/family ... objSFtp.ChangeDir( "/pictures/friends" ) ' Change directory to: /pictures/friends ... objSFtp.Disconnect ' Close the session End If
Description:
Create a new directory on the remote SFTP server in the directory indicated by GetCurrentDir.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.ChangeDir( "/pictures" ) ' Change directory to: /pictures objSFtp.CreateDir( "family" ) ' Create new directory 'family' ... objSFtp.Disconnect ' Close the session End If
Description:
Rename directory.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.RenameDir( "pictures", "images" ) ' Rename directory 'pictures' into 'images' ... objSFtp.Disconnect ' Close the session End If
Description:
Delete a directory.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.ChangeDir( "/pictures" ) ' Change directory to: /pictures objSFtp.DeleteDir( "family" ) ' Delete directory 'family' ... objSFtp.Disconnect ' Close the session End If
Description:
Find a file. You can use a plain filename (the file will then be retrieved from the current directory) or you can use a fully qualified filename.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then Set objSFtpFile1 = objSFtp.FindFile( "/pictures/picture1.jpg") ' Find file using a fully qualified filename ... objSFtp.ChangeDir( "/pictures" ) Set objSFtpFile2 = objSFtp.FindFile( "picture2.jpg") ' Find file using a plain filename objSFtp.Disconnect ' Close the session End If
Description:
Iterate over all files and directories in the search pattern. The search pattern can either be a directory or a wildcard search. The 'FindFirstFile' function retrieves the first file/directory. You can call 'FindNextFile' until there are no more files/directories.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then Set objSFtpFile = objSFtp.FindFirstFile(".") While( objSFtp.LastError = 0 ) WScript.Echo "File: " & objSFtpFile.Name ' Display filename (or directoryname) Set objSFtpFile = objSFtp.FindNextFile() WEnd objSFtp.Disconnect ' Close the session End If
Description:
Rename file.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.ChangeDir( "/pictures" ) ' Change directory to: /pictures objSFtp.RenameFile( "old.jpg", "new.jpg" ) ' Rename 'old.jpg' into 'new.jpg' ... objSFtp.Disconnect ' Close the session End If
Description:
Delete file.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.ChangeDir( "/pictures" ) ' Change directory to: /pictures objSFtp.DeleteFile( "picture1.jpg" ) ' Delete 'picture1.jpg' ... objSFtp.Disconnect ' Close the session End If
Description:
Download a file from the SFTP server.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.ChangeDir( "/pictures" ) ' Change directory to: /pictures objSFtp.GetFile( "picture1.jpg", "c:\pictures\file1.jpg" ) ' Download 'picture1.jpg' ... objSFtp.ChangeDir( "/" ) ' Change directory to: / objSFtp.GetFile( "/pictures/picture1.jpg", "c:\pictures\file1.jpg" ) ' Download 'picture2.jpg' objSFtp.Disconnect ' Close the session End If
Description:
Upload a file to the SFTP server.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 If( objSFtp.LastError = 0 ) Then ... objSFtp.ChangeDir( "/pictures" ) ' Change directory to: /pictures objSFtp.PutFile( "c:\pictures\picture3.jpg", "/pictures/picture3.jpg" ) ' Upload 'picture3.jpg' ... objSFtp.PutFile( "c:\pictures\picture4.jpg", "/pictures/picture4.jpg" ) ' Upload 'picture4.jpg' End If
Description:
GetErrorDescription provides the error description of a given error code.
Parameters:
Return value:
The error description that is associated with the given error code.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create a new SFtp instance ... objSFtp.Host = "SFtp1" objSFtp.UserName = "demo" objSFtp.Password = "demo" objSFtp.Connect ' Connect to host SFtp1 WScript.Echo "LastError: " & objSFtp.LastError WScript.Echo "Error description: " & objSFtp.GetErrorDescription( objSFtp.LastError ) ...
Description:
This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create Ftperver object
...
objSFtp.Sleep 50
Description:
This function activates the ActiveSocket product. A valid registration code is required.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSFtp = CreateObject( "ActiveXperts.SFtp" ) ' Create SFtp object objSFtp.Activate "xyz", True ' Substitute xyz by your own registrationkey ' Pass True to make the activation persistent, so you need to call ' Activate only once. If you pass False, you need to call ' Activate each time the product is started.
SNMP stands for Simple Network Management Protocol. Simple Network Management Protocol is a set of standards for communication with devices connected to a TCP/IP network. It is often used to communicate with hubs and switches.
Since it was developed in 1988, the Simple Network Managment Protocol has become the de facto standard for network management. Because it is a simple solution, requiring little code to implement, vendors can easily build SNMP agents to their products. SNMP is extensible, allowing vendors to easily add network management functions to their existing products. SNMP also separates the managment architecture from the architecture of the hardware devices, which broadens the base of multivendor support. Perhaps most important, unlike other so-called standards, SNMP is not a mere paper specification, but an implementation that is widely available today.
The ActiveSocket Snmp object enables you to add Snmp v1 and Snmp v2c functionality to your program.
Here is a small example (in VBScript) to show how to use the SnmpManager object:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object objSnmpManager.Initialize ' Initialize Snmp If( objSnmpManager.LastError <> 0 ) Then WScript.Echo "Initialize failed, error " & objSnmpManager.LastError WScript.Quit End If objSnmpManager.ProtocolVersion = objConstants.asSNMP_VERSION_V2c ' Set SNMP protocol version before opening SNMP session objSnmpManager.Open "192.168.1.10", "public" ' Open session to remote Snmp agent If( objSnmpManager.LastError <> 0 ) Then WScript.Echo "Error " & objSnmpManager.LastError Else objSnmpObject = objSnmpManager.Get( "system.sysName.0" ) ' Retrieve Object Identifier value If( objSnmpManager.LastError <> 0 ) Then WScript.Echo "Error " & objSnmpManager.LastError Else WScript.Echo "OID : " & objSnmpObject.Value ' Print Snmp data WScript.Echo " Value:" & objSnmpObject.Value ' Print Snmp data WScript.Echo " Type:" & objSnmpObject.Type ' Print Snmp data End If objSnmpManager.Close() ' Close session End If objSnmpManager.Shutdown ' Uninitialize Snmp
| Property | Type | In/Out | Mand/Opt | Description |
| OID | String | In/Out | M | SNMP Object Identifier |
| Type | Number | In/Out | M | SNMP data type |
| Value | String | In/Out | O | SNMP data value |
| RequestID | Number | Out | n/a | SNMP node ID |
| MIB properties (only set when used with the SnmpMibBrowser object): | ||||
| Name | String | Out | O | SNMP object name |
| Path | String | Out | O | SNMP full path object name |
| NodeID | String | Out | O | SNMP node ID |
| ParentNodeID | Number | Out | O | n/a |
| Syntax | String | Out | n/a | SNMP OID syntax |
| Access | Number | Out | n/a | SNMP OID Access |
| Status | Number | Out | n/a | SNMP OID Status |
| Function | Description |
| Clear | Reset all properties |
Type:
String
Description:
SNMP Object Identifier.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance ... Set objSnmpObject = objSnmpManager.Get( ".1.3.1.1.1.1" ) ' Get an SnmpObject object WScript.Echo "OID : " & objSnmpObject.OID ' Print OID WScript.Echo "Type : " & objSnmpObject.Type ' Print Type WScript.Echo "Value : " & objSnmpObject.Value ' Print Value
Type:
Number
Description:
SNMP data type. For an overview of all SNMP data types, check the SNMP Data Types section.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance ... Set objSnmpObject = objSnmpManager.Get( ".1.3.1.1.1.1" ) ' Get an SnmpObject object WScript.Echo "OID : " & objSnmpObject.OID ' Print OID WScript.Echo "Type : " & objSnmpObject.Type ' Print Type WScript.Echo "Value : " & objSnmpObject.Value ' Print Valuef
Type:
Variant
Description:
SNMP value as a string. The value type is indicated by the Type property.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance ... Set objSnmpObject = objSnmpManager.Get( ".1.3.1.1.1.1" ) ' Get an SnmpObject object WScript.Echo "OID : " & objSnmpObject.OID ' Print OID WScript.Echo "Type : " & objSnmpObject.Type ' Print Type WScript.Echo "Value : " & objSnmpObject.Value ' Print Value WScript.Echo "RequestID : " & objSnmpObject.RequestID ' Print RequestID
Type:
Number
Description:
This property indicates the request ID of the OID.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance ... Set objSnmpObject = objSnmpManager.Get( ".1.3.1.1.1.1" ) ' Get an SnmpObject object WScript.Echo "OID : " & objSnmpObject.OID ' Print OID WScript.Echo "Type : " & objSnmpObject.Type ' Print Type WScript.Echo "Value : " & objSnmpObject.Value ' Print Value WScript.Echo "RequestID : " & objSnmpObject.RequestID ' Print RequestID
Type:
String
Description:
'Name' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. This property indicates the plain name of the object.
Example:
Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" ) ' Create a new SnmpMibBrowser instance objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" ) ' Load MIB file Set objSnmp = objSnmpMIB.Get("iso") ' Get first OID WScript.Echo "OID Name: " & objSnmp.Name ' Display Name
Type:
String
Description:
'Path' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. This property indicates the full-path name of the object.
Example:
Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" ) ' Create a new SnmpMibBrowser instance objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" ) ' Load MIB file Set objSnmp = objSnmpMIB.Get("iso") ' Get first OID WScript.Echo "OID Name: " & objSnmp.Name ' Display Name WScript.Echo "OID Full-path Name: " & objSnmp.Path ' Display Full-patt Name
Type:
Number
Description:
'NodeID' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function.
This property indicates the node ID of the OID.
Example:
Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" ) ' Create a new SnmpMibBrowser instance objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" ) ' Load MIB file Set objSnmp = objSnmpMIB.Get("iso") ' Get first OID WScript.Echo "OID Name: " & objSnmp.Name ' Display Name WScript.Echo "NodeID: " & objSnmp.NodeID ' Display NodeID
Type:
Number
Description:
'ParentNodeID' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. This property indicates the parent node ID of the OID.
Example:
Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" ) ' Create a new SnmpMibBrowser instance objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" ) ' Load MIB file Set objSnmp = objSnmpMIB.Get("iso") ' Get first OID WScript.Echo "OID Name: " & objSnmp.Name ' Display Name WScript.Echo "ParentNodeID: " & objSnmp.ParentNodeID ' Display parent NodeID
Type:
Number
Description:
'Syntax' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. This property indicates the syntax of the object.
Example:
Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" ) ' Create a new SnmpMibBrowser instance objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" ) ' Load MIB file Set objSnmp = objSnmpMIB.Get("iso") ' Get first OID WScript.Echo "OID Name: " & objSnmp.Name ' Display Name WScript.Echo "Syntax: " & objSnmp.Syntax ' Display Syntax
Type:
Number
Description:
'Access' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. Click here for a list of valid Access values
Example:
Set objSnmpManager = CreateObject ( "ActiveXperts.SnmpManager") ' Create a new SnmpManager instance Set objConstants = CreateObject ( "ActiveXperts.ASConstants") objSnmpManager.Server = "ns1.interstroom.nl" ' Apply queries to DNS server ns1.interstroom.nl objSnmpManager.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA ' Lookup SOA record for activexperts.com If( objSnmpManager.LastError = 0 ) Then WScript.Quit End If Set objSnmpObject = objSnmpManager.GetFirstRecord ' Get first DNS record If( objSnmpManager.LastError = 0 ) Then WScript.Echo "Name: " & objSnmpObject.Name ' Display all SOA record fields WScript.Echo "NameServer: " & objSnmpObject.NameServer WScript.Echo "MailBox: " & objSnmpObject.MailBox WScript.Echo "NameServer: " & objSnmpObject.NameServer WScript.Echo "SerialNumber: " & objSnmpObject.SerialNumber WScript.Echo "RefreshInterval: " & objSnmpObject.RefreshInterval WScript.Echo "RetryInterval: " & objSnmpObject.RetryInterval WScript.Echo "ExpirationLimit: " & objSnmpObject.ExpirationLimit WScript.Echo "MinimumTTL: " & objSnmpObject.MinimumTTL End If
Type:
Number
Description:
'Status' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. Click here for a list of valid Status values
Example:
Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" ) ' Create a new SnmpMibBrowser instance objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" ) ' Load MIB file Set objSnmp = objSnmpMIB.Get("iso") ' Get first OID WScript.Echo "OID Name: " & objSnmp.Name ' Display Name WScript.Echo "Status: " & objSnmp.Status ' Display Status
Description:
Clears all properties of the object.
Parameters:
Return value:
Always 0.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance Set objSnmpObject = CreateObject( "ActiveXperts.SnmpObject" ) ' Create a new SnmpObject instance Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object ... objSnmpObject.Clear() ' Clear all properties objSnmpObject.OID = "1.3.1.2.3.4.5" objSnmpObject.Type = objConstants.asSNMP_TYPE_IPADDRESS objSnmpObject.Value = "10.1.1.10" objSnmpManager.Set( objSnmpObject ) ' SNMP Set
| Property | Type | In/Out | Mand/Opt | Description |
| Version | String | Out | n/a | Version number of ActiveSocket |
| Build | String | Out | n/a | Display build information of ActiveSocket |
| ExpirationDate | String | Out | n/a | Expiration date of ActiveSocket |
| Timeout | Number | In/Out | O | Number of millseconds before an SNMP operation will time out |
| ProtocolVersion | Number | In/Out | O | Specifies the SNMP protocol version to use |
| LastError | Number | In/Out | O | Result of the last called function |
| Function | Description |
| Initialize | Initialize the Snmp object |
| Shutdown | Shut down the Snmp object |
| Clear | Reset all properties to their default values |
| Open | Open an SNMP session to a remote host, using a specified community string |
| Close | Close the existing SNMP session |
| Get | Get the Snmp Data object of the specified OID (Object ID) from the (remote) SNMP agent |
| GetNext | Retrieve the next Snmp Data object from a table or list within an SNMP agent. |
| Set | Assign a new value to the specified OID (Object ID) on the (remote) SNMP agent |
| GetErrorDescription | Get the description of the given error |
| Sleep | Suspends the execution of the object for at least the specified interval |
| Activate | Activate Software |
Type:
String
Description:
Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objSnmpManager = CreateObject("ActiveXperts.SnmpManager") ' Create a new SnmpManager instance
WScript.Echo "Version: " & objSnmpManager.Version
Type:
String
Description:
Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.
Example:
Set objSnmpManager = CreateObject("ActiveXperts.SnmpManager") ' Create a new SnmpManager instance
WScript.Echo "Build: " & objSnmpManager.Build
Type:
String
Description:
Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
WScript.Echo "ExpirationDate: " & objSnmpManager.ExpirationDate
Type:
Number
Description:
UDP port number to identify a (remote) SNMP agent. If you don't specify the 'Port' property, port 161 (default SNMP port) is used.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance objSnmpManager.Initialize ' Initialize Snmp ... objSnmpManager.Port = 9000 ' Use port 9000 instead of default port 161 objSnobjSnmpManagermp.Open "192.168.1.10", "public" ' Connect to host 192.168.1.10, community public'
Type:
Number
Description:
Specifies the number of milliseconds before an SNMP operation times out. Default value: 5000 milliseconds.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance objSnmpManager.Initialize ' Initialize Snmp ... objSnmpManager.Timeout = 5000 ' Allow 5000 msecs until an SNMP operation times out objSnmpManager.Open "192.168.1.10", "public" ...
Type:
Number
Description:
Specifies the SNMP protocol version to use: asSNMP_VERSION_V1 or asSNMP_VERSION_V2C.
The default is version asSNMP_VERSION_V2C.
Note: To set the protocol version, you must set the 'ProtocolVersion' property before calling the Open function.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance Set objConstants = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object objSnmpManager.Initialize ' Initialize Snmp ... objSnmpManager.ProtocolVersion = objConstants.asSNMP_VERSION_V1 ' Use SNMP v1 protocol version. Set it before calling 'Open' objSnmpManager.Open "192.168.1.10", "public" ...
Type:
Number
Description:
The result of a previous called function.
Use it to check the result of your last function call.
A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance objSnmpManager.Initialize ' Initialize Snmp ... objSnmpManager.Open "192.168.1.10", "public" WScript.Echo "LastError: " & objSnmpManager.LastError ...
Description:
Initializes the Snmp object. Internally, the Initialize function initializes the WinSNMP libraries of the Operating System and allocates all necessary resources. You must call 'Initialize' before you can Open an SNMP session. You must call Shutdown to shut down the object (before unloading the Snmp object).
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance objSnmpManager.Initialize ' Initialize Snmp If( objSnmpManager.LastError = 0 ) objSnmpManager.Open "192.168.1.100", "public" ... objSnmpManager.Close ... objSnmpManager.Shutdown End If
Description:
Call this function to shut down the Snmp object. All resources of the object will be released.
Parameters:
Return value:
Always 0. Check LastError property to see if the function was completed successfully.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance objSnmpManager.Initialize ' Initialize Snmp If( objSnmpManager.LastError = 0 ) objSnmpManager.Open "192.168.1.100", "public" ... objSnmpManager.Close ... objSnmpManager.Shutdown ' Uninitialize Snmp End If
Description:
Resets all properties to the initial, default values. Use this function when you are opening/closing SNMP sessions multiple times.
Parameters:
Return value:
Always 0.
Example:
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance objSnmpManager.Initialize ' Initialize Snmp ... objSnmpManager.Open "192.168.1.100", "public" If( objSnmpManager.LastError = 0 ) ... objSnmpManager.Close End If objSnmpManager.Clear objSnmpManager.Open "192.168.1.200", "public" If( objSnmpManager.LastError = 0 ) ... objSnmpManager.Close End If objSnmpManager.Shutdown ' Uninitialize Snmp
Description:
Opens an SNMP session to a remote host, using a specified community string.
Parameters:
Return value: