Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about NET USE * /d

Status
Not open for further replies.

ISmonkey

MIS
Sep 6, 2001
62
FR
I have several machines that need all the mapped drives deleted and remapped using a batch file. I figured the quickest way to do it was add a NET USE * /d command at the start of the batch file and then map the drives that need to be added. The problem is, when you run the command, it prompts you for Y/N and waits there for an answer. Is there any way to add that input from the batch file itself or get around that prompt?
 
Yeah, try:

IF EXIST Z:\NUL NET USE Z: /DELETE >NUL
NET USE Z: \\SERVER\SHARE >NUL


By the way, I've used Z as an example drive. Just replace it with whatever.
Use the second line to map your drives.

Hope this helps...
 
The problem is we have some 300 users that use different drive mappings for different groups. I want to control their mappings by getting rid of all unnecessary drive mappings and recreate them through a batch file, that way the drive mappings follow the user and they only have access to the drives they need.
 
OK, so for example you have three workgroups : A, B and C.

Workgroup A is mapped to \\SERVER\FOLDER_A$
Workgroup B is mapped to \\SERVER\FOLDER_B$
Workgroup C is mapped to \\SERVER\FOLDER_C$

Workgroup A is mapped as F:
Workgroup B is mapped as G:
Workgroup C is mapped as H:

Set up some groups in User Manager For Domains, for example:
WORKGROUP_A
WORKGROUP_B
WORKGROUP_C

Give each workgroup permissions to the corresponding folder\share.

In the new logon script, use something along the lines of:

:WORKGROUP_A
ifmember WORKGROUP_A
if not errorlevel 1 goto WORKGROUP_B
ECHO Mapping WORKGROUP_A...
IF EXIST F:\NUL NET USE F: /DELETE > NUL
NET USE F: \\SERVER\FOLDER_A$ /PERSISTENT:NO > NUL
goto NEXT


:WORKGROUP_B
ifmember WORKGROUP_B
if not errorlevel 1 goto WORKGROUP_C
ECHO Mapping WORKGROUP_B...
IF EXIST G:\NUL NET USE G: /DELETE > NUL
NET USE G: \\SERVER\FOLDER_B$ /PERSISTENT:NO > NUL
goto NEXT


:WORKGROUP_C
ifmember WORKGROUP_C
if not errorlevel 1 goto NEXT
ECHO Mapping WORKGROUP_C...
IF EXIST H:\NUL NET USE H: /DELETE > NUL
NET USE H: \\SERVER\FOLDER_C$ /PERSISTENT:NO > NUL
goto NEXT


:NEXT
NEXT PART OF YOUR SCRIPT...
END

So this would set up a logon script for three workgroups. If you want someone to get the F drive, put them in Workgroup_A, if you want someone to get the G drive, put them into Workgroup B etc.

Another useful thing if you want to map someone a drive but it going to be a one off is to use:

REM Mapping USERNAME Z: Drive To Whatever Drive
if %username%==USERNAME NET USE Z: \\SERVER\SHARE$ /persistent:no > nul

Longest reply ever!

Let me know of this helps...
 
You can download an ifmember tool from microsoft, look for windows 2000 resource kit and download it, or I can email it to you. you can type things like:

ifmember Users
if errorlevel 1 goto END
net use z: \\server\share
 
Why do you guys need tools like 'ifmember' and so on ?
why don't we do it in old-fashion way ?


Create file called &quot;y.y&quot; and enter just one line containing &quot;Y&quot; (without quotes, ofcourse) in to it. Then you just run &quot;net use * /d < y.y&quot;.
 
does anybody hate it when they get an error message after hitting submit, forcing them to redo only to find they posted twice?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top