DevAdmin Blog

Blog di Ermanno Goletto (Microsoft MVP Directory Services - MCITP - MCTS - MCSA - MCP)
posts - 886, 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

Creare una share di rete tramite WMI

Tramite il seguente codice è possibile creare una share di rete senza fare ricorso alle Api (ovviamente con performance minori rispetto a quest'ultime).
I sistemi operativi supportati sono:

  • Windows Server 2003
  • Windows XP
  • Windows 2000 Professional/Server
  • Windows NT Workstation/Server 4.0 SP4 e successivi

Dim path As New System.Management.ManagementPath("Win32_Share")
Dim share As New System.Management.ManagementClass(Nothing, path, Nothing)

Dim inArgs As System.Management.ManagementBaseObject
inArgs = share.GetMethodParameters("Create")
inArgs("Path") = "C:\MyFolder"
inArgs("Name") = "ShareName"
'"ShareName$" for hide share
inArgs("Type") = 0
inArgs("MaximumAllowed") =
Nothing
inArgs("Description") = Nothing

Dim outArgs As System.Management.ManagementBaseObject
outArgs = share.InvokeMethod("Create", inArgs,
Nothing)

inArgs.Dispose() : inArgs = Nothing
outArgs.Dispose() : outArgs = Nothing
share.Dispose() : share = Nothing
path = Nothing

Per maggiori info sul metodo create della Win32_Share:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/create_method_in_class_win32_share.asp

Per uno script:
http://www.microsoft.com/technet/scriptcenter/scripts/storage/shares/stshvb01.mspx

 

Print | posted on Tuesday, August 30, 2005 7:51 AM | Filed Under [ Code, Snippets & Scripts IT .NET ]

Feedback

No comments posted yet.

Post Comment

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

Powered by:
Powered By Subtext Powered By ASP.NET