by Anonymous (267 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th May 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
WMI sample: create a share on a (remote) computer
' This sample creates a new share on a (remote) computer
' Check out http://www.activexperts.com/activmonitor for more samples and
' components
Sub CreateShare( strComputer, strFolder, strShareName )
Dim strObject, objPrintJobSet
Set objWMIShare = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2:Win32_Share")
objWMIShare.Create strFolder,strShareName,0
Set objWMIShare = Nothing
End Sub
' Main
Dim strComputer, strFolder, strShare
Do
strComputer = inputbox( "Please enter the name of a computer in your network (or . for local host)", "Input" )
Loop until strComputer <> ""
Do
strFolder = inputbox( "Please enter the folder you want to share (for example, c:\temp)", "Input" )
Loop until strFolder <> ""
Do
strShare = inputbox( "Please enter the name of the new share(for example, Temp)", "Input" )
Loop until strShare <> ""
CreateShare strComputer, strFolder, strShare
WScript.Echo( vbCrlf & "Ready." & vbCrlf & "Check out http://www.activxperts.com/activmonitor for more samples and components." )