








If you found any of the tools on this page helpful, any donations would be
appreciated.
|
Option Explicit
Dim objFSO
Dim WshShell
Dim WshNetwork
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject ("WSCript.shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
If Not IsCScript() Then
Wscript.echo WScript.FullName & " must be run with CScript."
Wscript.Quit 1
End if
Call Main()
Set objFSO = Nothing
Set WshShell = Nothing
Set WshNetwork = Nothing
Sub Main()
Dim bResult
If MapDrive ("X","\\W2KLewis02\My Music") Then
Wscript.echo "Mapped drive letter"
Else
Wscript.echo "Invalid path or drive letter"
End if
WshShell.Run "NET TIME /RTSDOMAIN:LEWIS"
If Not SetRegKey("HKLM\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\SMBDeviceEnabled",0, "REG_DWORD") THEN
Wscript.echo "Had problems writing RegKey"
End if
End Sub
Function SetRegKey(strKey, strValue, strType)
WshShell.RegWrite strKey, strValue, strType
SetRegKey = true
End Function
Function MapDrive(ByVal strDriveLetter, ByVal strPath)
Dim objRegExp
Dim iDrive
Dim bExists
Dim colDrives
Set objRegExp = New RegExp
strDriveLetter = UCase (strDriveLetter)
objRegExp.IgnoreCase = true
objRegExp.Pattern = "^[F-Z]$"
If Not objRegExp.Test (strDriveLetter) Then
MapDrive = False
Exit Function
End if
strDriveLetter = strDriveLetter & ":"
bExists = False
Set colDrives = WshNetwork.EnumNetworkDrives()
For iDrive = 0 To colDrives.Count - 1 Step 2
If colDrives.Item(iDrive) = strDriveLetter Then
bExists = True
End if
Next
If bExists Then
WShNetwork.RemoveNetworkDrive strDriveLetter, true
End if
WShNetwork.MapNetworkDrive strDriveLetter, strPath
WshShell.PopUp "Drive " & strDriveLetter & " connected to " & strPath & " successfully.", 5, "Logon", 0
MapDrive = True
End Function
Function IsCScript()
Dim objRegExp
Set objRegExp = New RegExp
objRegExp.IgnoreCase = true
objRegExp.Pattern = "cscript.exe$"
IsCScript = objRegExp.Test(WScript.FullName)
Set objRegExp = Nothing
End Function
|