Hi, I found the code below to create a share of the hard drive but when
I tried to apply it to share the DVD drive on the computer it failed.
Does any one have done this before? I think may intType should use
something else.

Please help.
Thanks

Greg
--------------------------------------

strComputer = "."
strPath = "t:\"
strName = "img"
intType = 0 ' share a disk drive resource
intMaxAllowed = 10
strDescr = "img on dvd"
' ------ END CONFIGURATION ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set objShare = objWMI.Get("Win32_Share")
intRC = objShare.Create(strPath, strName, intType, intMaxAllowed,
strDescr)
if intRC <> 0 then
WScript.Echo "Error creating share: " & intRC
else
WScript.Echo "Successfully created share"
end if

Re: Share DVD drive by greg_chu

greg_chu
Fri Sep 15 10:00:15 CDT 2006

I found the article and solved the problem.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/create_method_in_class_win32_share.asp

Greg

greg_chu@wendys.com wrote:
> Hi, I found the code below to create a share of the hard drive but when
> I tried to apply it to share the DVD drive on the computer it failed.
> Does any one have done this before? I think may intType should use
> something else.
>
> Please help.
> Thanks
>
> Greg
> --------------------------------------
>
> strComputer = "."
> strPath = "t:\"
> strName = "img"
> intType = 0 ' share a disk drive resource
> intMaxAllowed = 10
> strDescr = "img on dvd"
> ' ------ END CONFIGURATION ---------
> set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
> set objShare = objWMI.Get("Win32_Share")
> intRC = objShare.Create(strPath, strName, intType, intMaxAllowed,
> strDescr)
> if intRC <> 0 then
> WScript.Echo "Error creating share: " & intRC
> else
> WScript.Echo "Successfully created share"
> end if