Network - VBScript
Network Command
Overview
The Network command establishes and manages network connections in VB Script. It allows you to create, configure, and manipulate network objects, including drives, files, and printers.
Syntax
Network [Connect|Disconnect|Map|Unmap|Open|Close|Rename|Copy|Delete]
Options/Flags
| Option | Description | Default |
|—|—|—|
| Connect | Connects to a network drive | N/A |
| Disconnect | Disconnects from a network drive | N/A |
| Map | Maps a network drive to a local drive letter | N/A |
| Unmap | Unmaps a network drive from a local drive letter | N/A |
| Open | Opens a network file | N/A |
| Close | Closes a network file | N/A |
| Rename | Renames a network file or directory | N/A |
| Copy | Copies a network file or directory | N/A |
| Delete | Deletes a network file or directory | N/A |
Examples
Connect to a Network Drive
Network.Connect "\\server\share"
Unmap a Network Drive
Network.Unmap "Z:"
Open a Network File
Set file = Network.Open("\\server\share\file.txt")
Rename a Network File
Network.Rename "\\server\share\oldname.txt", "\\server\share\newname.txt"
Common Issues
- Permission denied errors: Ensure you have sufficient permissions to access the network resource.
- Connection timeout: Specify a timeout using the
Timeout
option in theConnect
method to avoid connection delays.
Integration
- Use the Network command in conjunction with the FileSystemObject to manage network files and directories.
- Combine with the File System Watcher to monitor network files for changes.
Related Commands
- GetObject: Gets a reference to a network object.
- CreateObject: Creates a new network object.
- FileSystemObject: Provides methods for manipulating files and directories.
- File System Watcher: Monitors files and directories for changes.