VBScript for Creating and Sharing a Folder

Nothing to type. The Code is well documented. :)

'--------------------------------------
'Script Start
'Owner - Imayakumar J.
'Date - December 5 2008
'--------------------------------------

'---------------------------------------------------------
' Get the Folder name
'---------------------------------------------------------

'wscript.Echo Date

dim thismonth, thisday, thisyear, foldername

'wscript.echo Month(Date)

thismonth = Month(Date)
thisday = Day(Date)
thisyear = Year(Date)

if len(thisday) = 1 then
thisday = "0"&thisday
end if

foldername = thismonth&thisday&thisyear

'----------------------------------------------------
'Create folder
'----------------------------------------------------

Dim filesys, returnvalue

Set filesys = CreateObject("Scripting.FileSystemObject")

'wscript.Echo returnvalue

filesys.createfolder "c:\"&foldername

'---------------------------------------------------------
' Check if another shar with the same name exists
'---------------------------------------------------------

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colShares = objWMIService.ExecQuery _
("Select * from Win32_Share Where Name = 'INGEST'")
For Each objShare in colShares
objShare.Delete
Next

'-----------------------------------------------------
' Share the created folder
'-----------------------------------------------------

Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
errReturn = objNewShare.Create _
("c:\"&foldername, "INGEST", FILE_SHARE, _
MAXIMUM_CONNECTIONS, "Notes to Exchange Migration Share.")

if errReturn = "0" then
wscript.echo "Success"
else
wscript.echo "Task Failed"
end if

'---------------------------------------------
' Script End
'-------------------------------———————

Enjoy !!