Windows 10 and logon.bat

Find logon scripts in AD user properties through AD PowerShell:

PS> Get-ADUser -filter * -properties scriptpath, homedrive, homedirectory | ft Name, scriptpath, homedrive, homedirectory

Also check  GPO.

Change your .bat script to .vbs and made changes inside by fllowing:

 

Option Explicit
Dim strDriveLetter
Dim objShell, objNetwork
Dim CheckDrive, AlreadyConnected, intDrive

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

REM --- Connect Drive W: \\SERVER\WORKSPACE ---

strDriveLetter = "W:"

On Error Resume Next
AlreadyConnected = False
For intDrive = 0 To CheckDrive.Count - 1 Step 2
If CheckDrive.Item(intDrive) =strDriveLetter Then AlreadyConnected =True
Next

If AlreadyConnected = True then
REM objShell.PopUp "Drive " & strDriveLetter & _ " is already connected"  
Set objNetwork = CreateObject("Wscript.Network")   objNetwork.RemoveNetworkDrive "W:", True, True 
objNetwork.MapNetworkDrive "W:", "\\CSNAS\WORKSPACE", True
Else
REM objShell.PopUp "Drive " & strDriveLetter & _ " is not connected."
Set objNetwork = CreateObject("Wscript.Network")   objNetwork.RemoveNetworkDrive "W:", True, True
objNetwork.MapNetworkDrive "W:", "\\CSNAS\WORKSPACE", True
End if

 

REM --- Connect Drive W: \\SERVER\UTILS ---

strDriveLetter = "K:"

On Error Resume
Next AlreadyConnected = False
For intDrive = 0 To CheckDrive.Count - 1 Step 2
If CheckDrive.Item(intDrive) =strDriveLetter Then AlreadyConnected =True
Next

If AlreadyConnected = True then
REM objShell.PopUp "Drive " & strDriveLetter & _ " is already connected"  
Set objNetwork = CreateObject("Wscript.Network")   objNetwork.RemoveNetworkDrive "K:", True, True 
objNetwork.MapNetworkDrive "K:", "\\CSNAS\UTILS", True
Else
REM objShell.PopUp "Drive " & strDriveLetter & _ " is not connected."
Set objNetwork = CreateObject("Wscript.Network")   objNetwork.RemoveNetworkDrive "K:", True, True
objNetwork.MapNetworkDrive "K:", "\\CSNAS\UTILS", True
End if

WScript.Quit


AUST IT - Computer help out of hours, when you need it most.

Find out why we do it for less.

About

AUST IT will help you resolve any technical support issues you are facing onsite or remotely via remote desktop 24/7. More...

Contacts

Reservoir, Melbourne,
3073, VIC, Australia

Phone: 0422 348 882

This email address is being protected from spambots. You need JavaScript enabled to view it.

Sydney: 0481 837 077

Connect

Join us in social networks to be in touch.

Newsletter

Complete the form below, and we'll send you our emails with all the latest AUST IT news.