Alex's Weblog

Weblog di Ermanno Goletto (Codename Alex - A Learning EXperience)
posts - 438, comments - 4214, trackbacks - 294

My Links

News

Il blog è stato
trasferito al
 seguente link:


DevAdmin Blog

Add my blog to Live

Foto

Curriculum Vitae


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 MCTS

Logo MCSA

Logo MCP

Logo Microsoft Certified Business Management Solutions Professional

Microsoft Certified Business Management Solutions Specialist


Logo UGIdotNET UGIdotNET Contributor


Logo UGISS UGISS Contributor


Logo SysAdmin.it SysAdmin.it Staff


Article Categories

Archives

Post Categories

Blogs

Database

Development

Friends

IT

Knowledge Base

Links

MBS

MCP

MVP Sites

User Groups

Virtualization

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 martedì 30 agosto 2005 12:51 | Filed Under [ Code & Snippet IT .NET Framework ]

Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET