Script mappatura unità di rete con protezione password utente
1.) Create a file and type on it the hostname or IP-Address, username and password on one line.
es: zeus or 10.10.0.2 danny !daNny!2010
2. Name the file "p" (just p without specifying the filetype
Now, create the batch file and name it whatever you want as follows:
==================== Start (Mapping.bat) =======================
@echo off
title Mapping Drives
cls
FOR /F "tokens=1-3 delims= " %%i IN (p) do (
set host=%%i
set ur=%%j
set pd=%%k
)
IF Exist Z: net use /del Z: /Y
net use Z: \\%host%\share /USER:%ur% %pd% /P:NO
:End
Exit
==================== End (Mapping.bat) =========================
Note:
--------
The /P:NO is optional and means no persistent mapping. This attribute could be switched on with /P:YES. Again it is exactly the same as writing /persistent:no or /persistent:yes.
Each time the host boots up, the drives could be mapped automatically (/P:YES) or not (/P:NO)
I always prefer to write protect and hide the "p" file. In this way, the file is not only invisible but also protected from accidental deletion.
Attenzione ai caratteri presenti nella password e alla lunghezza della stessa che potrebbero dar luogo ad una errata interpretazione del comando.