<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBS: Скрипт создания папок на файловом сервере]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=6884</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6884&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBS: Скрипт создания папок на файловом сервере».]]></description>
		<lastBuildDate>Wed, 29 Feb 2012 12:13:57 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[VBS: Скрипт создания папок на файловом сервере]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=57349#p57349</link>
			<description><![CDATA[<p>Коллеги, прошу помощи. Возникла срочная потребность создать структуру папок на файловом сервере.<br />Структура:&nbsp; Персональные_папки<br />----------------------------------------Отдел (OU)<br />-----------------------------------------------Пользователь (DisplayName)<br />---------------------------------------------------------------Домашняя<br />---------------------------------------------------------------Публичная<br />Права на просмотр для всех пользователей домена на всё до папок &quot;Домашняя&quot; и &quot;Публичная&quot;<br />на папку &quot;домашняя&quot; права только для пользователя, для папки &quot;Публичная&quot; чтение\запись для всех, удаление только для пользователя.<br />Сразу признаюсь, что в программирование не силен. Искал решение на VBS. Нашел скрипт, прошу помочь доработать под задачу. Заранее благодарен.<br /></p><div class="codebox"><pre><code>On Error Resume Next 

Dim strUser 
Dim strOU 
Dim strPath 

Const OU = &quot;OU=Пользователи&quot; 
Const ShareFolder = &quot;D:\Share\Персональные_папки&quot; 

Set oShell = CreateObject(&quot;WScript.Shell&quot;) 
Set WshShell = CreateObject(&quot;WScript.Shell&quot;) 
Set FileSys = CreateObject(&quot;Scripting.FileSystemObject&quot;) 
Set objConnection = CreateObject(&quot;ADODB.Connection&quot;) 
Set objCommand = CreateObject(&quot;ADODB.Command&quot;) 
objConnection.Provider = &quot;ADsDSOOBject&quot; 
objConnection.Open &quot;Active Directory Provider&quot; 
Set objCommand.ActiveConnection = objConnection 

Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;) 
strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;) 

strFilter = &quot;(&amp;(objectCategory=user))&quot; 
strQuery = &quot;&lt;LDAP://&quot; &amp; OU &amp; &quot;,&quot; &amp; strDNSDomain &amp; &quot;&gt;;&quot; &amp; strFilter &amp; &quot;;distinguishedName&quot;
 objCommand.CommandText = strQuery 
Set objRecordSet = objCommand.Execute 

Do Until objRecordSet.EOF 
  strDN = objRecordSet.Fields(&quot;distinguishedName&quot;) 
  Set objUser = GetObject(&quot;LDAP://&quot; &amp; strDN) 
  
  If objUser.AccountDisabled = False Then 
    strUser = objUser.Get(&quot;Displayname&quot;) 
    
    strOU = objUser.AdsPath 
    strOU = Right(strOU, Len(strOU) - InStr(strOU, &quot;OU&quot;) - 2) 
    strOU = Left(strOU, InStr(strOU, &quot;,&quot;) - 1) 
    
    Err.Clear 
    Set objGroup = GetObject(&quot;LDAP://CN=&quot; &amp; strOU &amp; &quot;,OU=Groups,&quot; &amp; OU &amp; &quot;,&quot; &amp; strDNSDomain)
     If (Err.Number = &quot;-2147016656&quot;) Then 
      Err.Clear 
      Set objOU = GetObject(&quot;LDAP://OU=Groups,&quot; &amp; OU &amp; &quot;,&quot; &amp; strDNSDomain) 
      Set objGroup = objOU.Create(&quot;Group&quot;, &quot;CN=&quot; &amp; strOU) 
      objGroup.Put &quot;sAMAccountName&quot;, strOU 
      objGroup.Put &quot;description&quot;, strOU 
      objGroup.SetInfo 
    End If 
    
    objGroup.Add objUser.AdsPath 
    
    strPath = ShareFolder &amp; &quot;\&quot; &amp; strOU 
    If Not FileSys.FolderExists(strPath) Then 
      Call FileSys.CreateFolder(strPath) 
      Call FileSys.CreateFolder(strPath &amp; &quot;\Home&quot;) 
      Call FileSys.CreateFolder(strPath &amp; &quot;\Pub&quot;) 
      Call WshShell.Run(&quot;cacls &quot; &amp; strPath &amp; &quot;\Pub&quot; &amp; &quot; /e /g &quot; &amp; strOU &amp; &quot;:C&quot;, HIDE_WINDOW, WAIT_ON_RETURN)
     End If 
    
    strPath = strPath &amp; &quot;\Home\&quot; &amp; strUser 
    If Not FileSys.FolderExists(strPath) Then 
      Call FileSys.CreateFolder(strPath) 
      Call WshShell.Run(&quot;cacls &quot; &amp; strPath &amp; &quot; /e /g &quot; &amp; strUser &amp; &quot;:C&quot;, HIDE_WINDOW, WAIT_ON_RETURN)
     End If 
  End If 
  objRecordSet.MoveNext 
Loop</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (vmolbo)]]></author>
			<pubDate>Wed, 29 Feb 2012 12:13:57 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=57349#p57349</guid>
		</item>
	</channel>
</rss>
