Link to home
Start Free TrialLog in
Avatar of Network_Padawan
Network_Padawan

asked on

Beginning to learn VB scripting...some help

I am just learning how to vbscript, I needed a script that maps and disconnects network drives for users that logon on the domain. I found the following scripts and they work, I just need help understanding the actual code...if anyone can please help me

To map a network drive

Set objNetwork = CreateObject("WScript.Network")  ...What is Wscript.Network??? Where does VBscript get this obeject from and what does it do?
Set objShell = CreateObject("WScript.Shell")...Same as above...What is Wscript.Shell?
DriveLetter1 = "P:"
RemotePath1 = "\\alan\Drivers"

objNetwork.MapNetworkDrive DriveLetter1, RemotePath1
objShell.PopUp "Drive " & DriveLetter1 & " connected successfully."

Wscript.Quit

' End of example VBScript

To disconnect a network drive

Option Explicit       .... What does this mean?
Dim objShell, objNetwork, DriveLetter1   ...What is dim?
DriveLetter1 = "P:"

Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")

objNetwork.RemoveNetworkDrive DriveLetter1
objShell.PopUp "Drive " & DriveLetter1 & " disconnected."

Wscript.Quit

' End of example VBScript

Thanks guys
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

WScript.Network is a scripting object that provides methods and properties that allow for manipulation of network objects see here :
http://msdn.microsoft.com/en-us/library/s6wt333f(v=vs.85).aspx

WScript.shell allows you to manipulate environment variables and the like see here :
http://msdn.microsoft.com/en-us/library/aew9yb99(v=vs.85).aspx

Option Explicit means that all variables have to be declared see here :
http://msdn.microsoft.com/en-us/library/t7zd6etz(v=vs.85).aspx

DIM is used to dimension or declare variables see here :
http://msdn.microsoft.com/en-us/library/t7zd6etz(v=vs.85).aspx
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Network_Padawan
Network_Padawan

ASKER

Awesome! Thanks