Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to modify Shared Folder properties with VBScript?

Status
Not open for further replies.

patrick20009DC

IS-IT--Management
Oct 9, 2007
1
US
Hello experts,

I am reasonably proficient in VBScript, and am searching for a way to accomplish a specific task. I can create or delete folder shares with a VBScript just fine, but I don't know how to access some of the properties of the share. Specifically, I want to create a script that will disable caching of files in the shared folder. Would anyone know what the objects/properties/methods are to access this particular setting of the file share ? Appreciate any tips offered, or simply a pointer in the right direction.

thanks
-patrick
 
Well, I'm trying to find that myself (although mostly in terms of just being complete about a Share's settings).

Found this so far for the more obvious share settings (Scriptomatic.hta is a wonderful thing):
Code:
On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("ServerName")
For Each strComputer In arrComputers
   WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Share", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      WScript.Echo "AccessMask: " & objItem.AccessMask
      WScript.Echo "AllowMaximum: " & objItem.AllowMaximum
      WScript.Echo "Caption: " & objItem.Caption
      WScript.Echo "Description: " & objItem.Description
      WScript.Echo "InstallDate: " & WMIDateStringToDate(objItem.InstallDate)
      WScript.Echo "MaximumAllowed: " & objItem.MaximumAllowed
      WScript.Echo "Name: " & objItem.Name
      WScript.Echo "Path: " & objItem.Path
      WScript.Echo "Status: " & objItem.Status
      WScript.Echo "Type: " & objItem.Type
      WScript.Echo
   Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm: 
	WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
	Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
	& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Still trying to find the setting for Caching (I suspect 'Offline Access' is the phrase that's more likely to be relevant)...

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top