Skip to content

Instantly share code, notes, and snippets.

@Wildcarde
Last active September 8, 2015 15:10
Show Gist options
  • Save Wildcarde/b90e32fb59aafb055cb1 to your computer and use it in GitHub Desktop.
Save Wildcarde/b90e32fb59aafb055cb1 to your computer and use it in GitHub Desktop.
This is a simple batch script I put together for automatically mounting a users shared drive when they log into one of our domain auth'd lab machines. We didn't have direct control over the OU behavior of these machines so we couldn't add a group policy rule, this is an effective workaround for that problem.
@echo off
net use * /delete /yes
cls
set i=0
set group="Domain Users"
for /f %%f in ('"gpresult /user %USERNAME% /R | findstr /i %group%"') do set /a i=%i%+1
if %i% gtr 0 (goto :member)
:nomember
goto :end
:member
net use z: \\<server fqdn>\<sharename>
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment