If you have to remove a printer que from you clients computers, using a logon script, you can do the following:
ECHO Attempting to disconnect mapped printers...
rundll32 printui.dll,PrintUIEntry /dn /q /n"\\SERVER\PRINTER"
ECHO Attempting to logoff from server...
NET USE \\SERVER\PRINTER /DELETE
If you work in a ActiveDirectory based environment and all your clients are connected to the domain, you might not have to deal with manually map home drives and other resources.
However, if some of your clients are not connected to the domain, but need access to domain resources, you probably noticed that it can be pretty annoying having service calls because of forgotten network paths and locked accounts.
To encounter that problem, I wrote a quick and dirty script, which gives the user a basic dialogue driven netdrive-mapper, so your service desk gets rid of the most basic calls.
ECHO Removing all available mappings...
NET USE * /D
ECHO Attempting to connect to SERVER and map your homedrive...
SET /P USER=Please enter your username (email@example.com):
NET USE U: \\server.domain.local\%USER:~0,-13%$ /USER:%USER% /PERSISTENT:NO
ECHO Attempting to connect to SERVER and map your Groupdrives...
SET /P GROUP1=Please enter your main Group:
NET USE V: \\server.domain.local\%GROUP1% /PERSISTENT:NO
SET /P CONTINUE=Add another Groupdrive? (y or n)
IF /I '%CONTINUE%'=='y' GOTO GROUP2
IF /I '%CONTINUE%'=='n' GOTO PUB
ECHO "%CONTINUE%" is not valid. Going to map public drives GOTO PUB
SET /P GROUP2=Please enter your second Group:
NET USE W: \\server.domain.local\%GROUP2% /PERSISTENT:NO
ECHO Attempting to connect to SERVER and map public drives...
NET USE p: \\server.domain.local\public /USER:%USER% /PERSISTENT:NO
ECHO Attempting to connect to SERVER and map printers...
Recently, I got the task to remove all MP3- files from some shared folders (SMB shares). To do so, I wrote a tiny batch- script wich processes the DIR command’s output and examines it to match the MP3 extension.
The script processes all folders and subfolders in its working directory (e.g. if you run it in c:\scripts it processes all folders and subfolders from there on – c:\scripts\*)
FOR /F "tokens=*" %%G IN ('DIR /B /S *.mp3') DO DEL /F "%%G"