根据用户组映射网络磁盘

Published on 2014 - 09 - 09

以前在赛诺格兰上班的时候写的一个script
开机自动删除所有网络驱动器(网络磁盘)并且自动根据自己的用户组来映射相应的磁盘!下面是代码


@echo off
@color 0a
lsrunase /user:administrator /password:7F1z3qRdsg== /domain: /command:DNS.bat /runpath:c:\
net use * /del /y
net use x: \beifps01\training$
net use y: \beifps01\phonebook$
net use z: \beifps01\public$
for /f "delims=" %%a in ('net user %username% /domain^|find "_BEI-System"') do set group=%%a
set str=%group%
if "%str%"=="" (echo .) else (net use q: \beifps01\system$)
for /f "delims=" %%b in ('net user %username% /domain^|find "_BEI-SoftwareDev"') do set group1=%%b
set str1=%group1%
if "%str1%"=="" (echo .) else (net use p: \beifps01\SoftwareDev$)
for /f "delims=" %%c in ('net user %username% /domain^|find "_BEI-Finance"') do set group2=%%c
set str2=%group2%
if "%str2%"=="" (echo .) else (net use o: \beifps01\Finance$)
for /f "delims=" %%d in ('net user %username% /domain^|find "_BEI-Administration"') do set group3=%%d
set str3=%group3%
if "%str3%"=="" (echo .) else (net use n: \beifps01\Administration$)
for /f "delims=" %%e in ('net user %username% /domain^|find "_BEI-Mechanics"') do set group4=%%e
set str4=%group4%
if "%str4%"=="" (echo .) else (net use r: \beifps01\Mechanics$)
for /f "delims=" %%f in ('net user %username% /domain^|find "_BEI-HR"') do set group5=%%f
set str5=%group5%
if "%str5%"=="" (echo .) else (net use s: \beifps01\HR$)
for /f "delims=" %%g in ('net user %username% /domain^|find "_BEI-Electronics"') do set group6=%%g
set str6=%group6%
if "%str6%"=="" (echo .) else (net use t: \beifps01\electronics$)
for /f "delims=" %%h in ('net user %username% /domain^|find "_BEI-Detector"') do set group7=%%h
set str7=%group7%
if "%str7%"=="" (echo .) else (net use u: \beifps01\Detector$)
for /f "delims=" %%i in ('net user %username% /domain^|find "_BEI-Algorithm"') do set group8=%%i
set str8=%group8%
if "%str8%"=="" (echo .) else (net use v: \beifps01\algorithm$)
for /f "delims=" %%j in ('net user %username% /domain^|find "_BEI-ITTeam"') do set group9=%%j
set str9=%group9%
if "%str9%"=="" (echo .) else (net use w: \beifps01\IT$)
pause