Is there a way in my current login script to delete any printers/drive mappings before its starts with the new ones?

This question is pretty straight forward.  Is there a way in my current login script to delete any printers/drive mappings before its starts with the new ones?  I'm running a SBS 2K3 server.  Thanks in advance.  
GTKINCAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Andrew DavisManagerCommented:
presuming you are running vbs script
there are a few ways of doing this depending if you know what printers they are likley to have.
read http://www.computerperformance.co.uk/Logon/Logon_Remove_Printer.htm
this will send you in the right direction.

Regards
Andrew
0
murgroupCommented:
net use i: /delete /yes
net use s: /delete /yes

rundll32 printui.dll,PrintUIEntry /dn /q /n "\\server\printername"

0
Steve KnightIT ConsultancyCommented:
To delete all drive mappings and printer mappings to LPT ports from a batch file without knowing the mappings

net use * /delete /y

hth

Steve
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

GTKINCAuthor Commented:
i'm using the .bat file.  They are ran when the users log in.  Their batch files depend on what group they are in.  Hope this helps.
0
Steve KnightIT ConsultancyCommented:
See above then

REM Remove all existing mappings
net use * /delete /y
REM Turn off persistence so new drive mappings don't stick
net use /persistent:no
REM New drive mappings
NET USE s: \\server\shared

As to printers the NET USE * /delete /y will remove any mappings from printers to LPT1/2/3 but connections to printers on the server you need to know the old printer names and use the printui.dll commands as posted above by murgroup.  More info. on the options available can eb found in various places, e.g. here --> http://www.dx21.com/SCRIPTING/RUNDLL32/VIEWITEM.ASP?OID=145&CMD=P-A

Steve
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
canaliCommented:
This is the line needed to delete any printers/drive mappings
bye Gastone Canali
::
::  rm-net-mappings.cmd
:: *** delete any printers/drive mappings ***
::
:: *** remove all network disk mappings
net use * /del /y
:: Turn off persistence
net use /persistent:no
:: *** remove all network printer mappings
reg delete HKCU\Printers\Connections /f
::  *** end
::
::  rm-net-mappings.cmd
:: *** delete any printers/drive mappings ***
::
:: *** remove all network disk mappings
net use * /del /y
:: Turn off persistence 
net use /persistent:no
:: *** remove all network printer mappings
reg delete HKCU\Printers\Connections /f
::  *** end

Open in new window

0
canaliCommented:
again ...
net use * /del /y
net use /persistent:no
:: more elegant way to remove mapped printer
WMIC /INTERACTIVE:Off PRINTER where network='TRUE' delete

Bye Gastone
0
GTKINCAuthor Commented:
Thanks for your time.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.