aqFileSystem.DisconnectNetworkDrive Method

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Use the DisconnectNetworkDrive method to discard the existing connection to a network resource.

Declaration

aqFileSystem.DisconnectNetworkDrive(Name, Force, Remember)

Name [in]    Required    String    
Force [in]    Optional    Boolean Default value: False   
Remember [in]    Optional    Boolean Default value: True   
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Name

Specifies the name of either the network resource you want to disconnect from, or the local device whose redirection you want to cancel.

If the connection you want to discard does not have a redirected device, specify the name of the network resource, for example, “\\Tester\WorkDirectory”. Otherwise, specify the name of the local device, for example, “Z:”. Note that the parameter's value can also contain values in any of the following formats: IPv4 address (for example, "\\192.168.1.1\share") and IPv6 address (for example, "\\2001-4898-9-3-c069-aa97-fe76-2449.ipv6-literal.net\share").

Force

Specifies whether the connection should be canceled if there are opened files or transactions on the connection. If Force is False, which is the default value, and there are opened files or transactions, the method fails to disconnect form the network resource.

Remember

Specifies whether TestComplete will establish a connection to the specified network drive automatically next time you log in to the system under the current user account.

Result Value

If the connection is canceled successfully, the method returns zero. Otherwise, it returns an error code. To get a description that corresponds to the given error code, you can use the aqUtils.SysErrorMessage method. The complete list of error codes is provided in the System Error Codes article in the MSDN library.

Example

The following code snippet cancels connection to the \\Tester\WorkDirectory network folder that does not have any redirected local device specified.

JavaScript, JScript

aqFileSystem.DisconnectNetworkDrive("\\\\Tester\\WorkDirectory");

Python

aqFileSystem.DisconnectNetworkDrive("\\\\Tester\\WorkDirectory")

VBScript

aqFileSystem.DisconnectNetworkDrive("\\Tester\WorkDirectory")

DelphiScript

aqFileSystem.DisconnectNetworkDrive('\\Tester\WorkDirectory');

C++Script, C#Script

aqFileSystem["DisconnectNetworkDrive"]("\\\\Tester\\WorkDirectory");

The following code snippet cancels connection to the network folder redirected to the “Z:” local device.

JavaScript, JScript

aqFileSystem.DisconnectNetworkDrive("Z:");

Python

aqFileSystem.DisconnectNetworkDrive("Z:")

VBScript

aqFileSystem.DisconnectNetworkDrive("Z:")

DelphiScript

aqFileSystem.DisconnectNetworkDrive('Z:');

C++Script, C#Script

aqFileSystem["DisconnectNetworkDrive"]("Z:");

See Also

MapNetworkDrive Method
aqFileSystem Object
Drives Property
aqFolderInfo Object
SysErrorMessage Method

Highlight search results