DevAdmin Blog

Blog di Ermanno Goletto (Microsoft MVP Directory Services - MCITP - MCTS - MCSA - MCP)
posts - 887, comments - 447, trackbacks - 13

My Links

News

Avatar

Curriculum Vitae

Visualizza il profilo di Ermanno Goletto su LinkedIn


Il contenuto di questo blog e di ciascun post viene fornito “così come é”, senza garanzie, e non conferisce alcun diritto. Questo blog riporta il mio personale pensiero che non riflette necessariamente il pensiero del mio datore di lavoro.

Logo Creative Commons Deed


Logo SysAdmin.it SysAdmin.it Staff


Logo TechNet Forum TechNet Italia @ForumTechNetIt Follow TechNet Forum on Twitter


Logo MVP


Ermanno Goletto Follow ermannog on Twitter

Article Categories

Archives

Post Categories

Blogs

Friends

Knowledge Base

MVP Sites

Resources

Script per tentare la mappatura di una share di rete

Per assegnare in modo automatico una lettera ad una share di rete è possibile utilizzare il comando:
NET USE *

Questo comando però in Windows XP parte da Z ad assegnare la lettera mentre su Windows 2000 parte dalla prima libera fino ad arrivare alla Z.

Se si vuole uniformare il comportamento è necessario uno script, che ha anche il pregio di forzare il tentativo in determinati range.

Di seguito uno script vbs e un batch tentare la mappatura sulle lettere X,Y,S

Dim letters, WshNetwork, Fso

letters = Array("X","Y","S")

Set WshNetwork=WScript.CreateObject("WScript.Network")

Set Fso = WScript.CreateObject("Scripting.FileSystemObject")

For Each letter In letters
    If (Not fso.DriveExists(letter)) Then
 WshNetwork.MapNetworkDrive letter & ":", "\\ComputerName\ShareName"
        Exit For
    End If
Next

Set letters = Nothing
Set WshNetwork = Nothing
Set Fso = Nothing


Di seguito un batch tentare la mappatura sulle lettere X,Y,S

SETLOCAL

REM Search Letter

FOR %%l in (X Y S) DO (
  IF NOT EXIST %%l: (
    SET FirstAvailableDrive=%%l:
    GOTO :EndSearchLetter
  )
)

:EndSearchLetter

IF "%FirstAvailableDrive%" GTR "" (
  NET USE %FirstAvailableDrive% \\ComputerName\ShareName /persistent:no
)

ENDLOCAL

Print | posted on Thursday, October 26, 2006 10:47 AM | Filed Under [ Code, Snippets & Scripts IT ]

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 3 and 4 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET