Geates what you say isn't working as it isn't the complete script
i'll post the complete source the textfile grous.txt has the security groups per line
it's a bit messy but it works except for the complete status issue
<html>
<HTA:APPLICATION
APPLICATIONNAME="create Tam Share "
SCROLL="no"
SINGLEINSTANCE="yes"
<head>
<title>Create /add Tam group to D share of server</title>
<!-- <style type="text/css">
.style3 {font-size: 13px}
body,td,th {
font-family: Arial, Helvetica, sans-serif;
}
.style2 { font-family: Arial, Helvetica, sans-serif;
font-size: 13.5pt;
color: #CC6600;
font-weight: bold;
}
.style5 {font-size: small; color: #FF0000; }
.style6 {color: #FF0000}
div
{
text-align: center;
}?
</style> -->
<SCRIPT LANGUAGE="VBScript">
Sub Window_onLoad
intWidth = 450
intHeight = 435
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
window.resizeTo 450,435
Set objShell = CreateObject("WScript.Shell")
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1406", 0, "REG_DWORD"
LoadDropDown
End Sub
</SCRIPT>
<script type="text/vbscript">
'read file with groups and text area with server names
Sub LoadDropDown
ForReading = 1
strNewFile = "Groups.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile _
(strNewFile, ForReading)
Do Until objFile.AtEndOfStream
strserver = objFile.ReadLine
Set objOption = Document.createElement("OPTION")
objOption.Text = strserver
objOption.Value = strserver
Groups.Add(objOption)
Loop
objFile.Close
End Sub
Sub filterserver 'filter out empty line and death server text area
strgroup = Groups.Value
strText = serverTextArea.Value
arrLines = Split(strText, vbCrLf)
For Each strserver in arrLines
If strserver <> "" Then
strPingStatus = PingStatus(strserver)
If strPingStatus = "Success" Then
checkshare strserver, strgroup
Else
MsgBox " server: " & strserver & " is not online or does not exist, rerun script with the correct servername script will continu with next server"
'On Error Resume Next
End If
End If
next
End Sub
Sub checkshare(strserver, strgroup) ' check if share exists
sShareName = "TAM-Share"
snode = strserver
If ExistShare(sNode, sShareName) Then
addshare strserver, strgroup, sShareName
Else
createshare strserver, strgroup, sShareName
End If
End Sub
Sub createshare(strserver, strgroup, sShareName) ' create share when not exist
Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25
Dim objWMIService
Dim objNewShare
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strserver & "\root\cimv2")
Set objNewShare = objWMIService.Get("Win32_Share")
Call setsharesec ("C:\", sShareName, sShareName,strgroup, strserver)
End Sub
Sub setsharesec(Fname,shr,info,strgroup,strserver) 'Fname = Folder path, shr = Share name, info = Share Description, account = account or group you are assigning share permissions to
Dim FSO
Dim Services
Dim SecDescClass
Dim SecDesc
Dim Trustee1
Dim ACE
Dim Share
Dim InParam
Dim Network
Dim FolderName
Dim AdminServer
Dim ShareName
FolderName = Fname
AdminServer = "\\" & strserver
ShareName = shr
Set Services = GetObject("WINMGMTS:{impersonationLevel=impersonate,(Security)}!" & AdminServer & "\ROOT\CIMV2")
Set SecDescClass = Services.Get("Win32_SecurityDescriptor")
Set SecDesc = SecDescClass.SpawnInstance_()
Set Trustee1 = SetgroupTrustee("paccar-eu", strgroup)
'To assign permissions to individual accounts use SetAccountTrustee rather than SetGroupTrustee
Set ACE = Services.Get("Win32_Ace").SpawnInstance_
ACE.Properties_.Item("AccessMask") = 1179817
ACE.Properties_.Item("AceFlags") = 3
ACE.Properties_.Item("AceType") = 0
ACE.Properties_.Item("Trustee") = Trustee1
SecDesc.Properties_.Item("DACL") = Array(ACE)
Set Share = Services.Get("Win32_Share")
Set InParam = Share.Methods_("Create").InParameters.SpawnInstance_()
InParam.Properties_.Item("Access") = SecDesc
InParam.Properties_.Item("Description") = Info
InParam.Properties_.Item("Name") = ShareName
InParam.Properties_.Item("Path") = FolderName
InParam.Properties_.Item("Type") = 0
Share.ExecMethod_ "Create", InParam
Setntfssec strserver, strgroup
End Sub
Sub addshare(strserver, strgroup, sShareName) ' add extra group to existing share
computer = strserver
username = strgroup
share = sShareName
domain = CreateObject("WScript.Network").UserDomain
' copy existing ACEs
Set objLocator = CreateObject("wbemscripting.swbemlocator")
Set wmi = objLocator.ConnectServer(Computer) 'THIS IS THE NAME OF THE COMPUTER YOU ARE SETTING PERMISSIONS ON
wmi.security_.impersonationlevel = 3
wmi.security_.privileges.AddAsString("SeSecurityPrivilege")
set shareSec = wmi.Get("Win32_LogicalShareSecuritySetting.Name='" & Share & "'")
rc = shareSec.GetSecurityDescriptor(sd)
flags = sd.ControlFlags
ReDim acl(UBound(sd.DACL)+1) '+1 for the new ACL we're going to add
For i = 0 To UBound(sd.DACL)
Set acl(i) = sd.DACL(i)
Next
Set sd = Nothing
' add new ACE
Set acl(UBound(acl)) = NewACE(NewTrustee(username, domain))
' prepare new security descriptor
Set sd = wmi.Get("Win32_SecurityDescriptor").SpawnInstance_
sd.ControlFlags = flags
sd.DACL = acl
' assign new security descriptor
rc = shareSec.SetSecurityDescriptor(sd)
Setntfssec strserver, strgroup
End sub 'shareadd
Function NewTrustee(name, domain)
Set objLocator = CreateObject("wbemscripting.swbemlocator")
Set wmi = objLocator.ConnectServer(Computer)
Dim trustee, account
Set trustee = wmi.Get("Win32_Trustee").SpawnInstance_
trustee.Name = name
trustee.Domain = domain
set account = getObject("Winmgmts:{impersonationlevel=impersonate}!root/cimv2:Win32_Account.Name='" & Name & "',Domain='" & Domain &"'")
trustee.Properties_.Item("SID") = wmi.Get("Win32_SID.SID='" & account.SID _
& "'").BinaryRepresentation
Set NewTrustee = trustee
End Function
Function NewACE(trustee)
Set objLocator = CreateObject("wbemscripting.swbemlocator")
Set wmi = objLocator.ConnectServer(Computer)
Dim ace1 : Set ace1 = wmi.Get("Win32_Ace").SpawnInstance_
ace1.Properties_.Item("AccessMask") = 1179817
ace1.Properties_.Item("AceFlags") = 3
ace1.Properties_.Item("AceType") = 0
ace1.Properties_.Item("Trustee") = trustee
Set NewACE = ace1
End Function
Sub Setntfssec(strserver, strgroup)
Dim strDdrive
Dim intRunError, objShell, objFSO
strDdrive = "\\" & strserver & "\" & "C$"
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPermision = strgroup & "

CI)(OI)RX"
intRunError = objShell.Run("cmd /c icacls.exe " & strDdrive & " /T /grant:r " & "paccar-eu\" & strPermision & " /inheritance:e")
createadmin strserver
End Sub
Sub createadmin(strserver)
Dim WshShell, fso
Set WSHShell =CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists("\\" & strserver & "\" & "C$" & "\Admin") = False Then
fso.CreateFolder("\\" & strserver & "\" & "C$\Admin")
End If
Dim objShell, intRunError
Set objShell = CreateObject("Wscript.Shell")
intRunError = objShell.Run("icacls.exe \\" & strserver & "\C$\Admin /inheritance:r /grant:r administrators

CI)(OI)F",2 ,True)
End sub
Function ExistShare(sComputer, sShare) ' check if share already exists
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set colShares = oWMI.ExecQuery _
("Select * from Win32_Share WHERE name = '" & sShare & "'")
If colShares.Count > 0 Then
ExistShare = True
Else
ExistShare = False
End If
End Function
Function PingStatus(strComputer) ' check if server is online
strWorkstation = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strWorkstation & "\root\cimv2")
Set colPings = objWMIService.ExecQuery _
("SELECT * FROM Win32_PingStatus WHERE Address = '" & strComputer & "'")
For Each objPing in colPings
Select Case objPing.StatusCode
Case 0 PingStatus = "Success"
Case Else PingStatus = "Failure"
End Select
Next
End Function
Function SetAccountTrustee(strDomain, strName)
Dim objTrustee
Dim account
Dim accountSID
set objTrustee = getObject("Winmgmts:{impersonationlevel=impersonate}!root/cimv2:Win32_Trustee").Spawninstance_
set account = getObject("Winmgmts:{impersonationlevel=impersonate}!root/cimv2:Win32_Account.Name='" & strName & "',Domain='" & strDomain &"'")
set accountSID = getObject("Winmgmts:{impersonationlevel=impersonate}!root/cimv2:Win32_SID.SID='" & account.SID &"'")
objTrustee.Domain = strDomain
objTrustee.Name = strName
objTrustee.Properties_.item("SID") = accountSID.BinaryRepresentation
set accountSID = nothing
set account = nothing
set SetAccountTrustee = objTrustee
End Function
Function SetGroupTrustee(strDomain, strName)
Dim objTrustee
Dim account
Dim accountSID
set objTrustee = getObject("Winmgmts:{impersonationlevel=impersonate}!root/cimv2:Win32_Trustee").Spawninstance_
set account = getObject("Winmgmts:{impersonationlevel=impersonate}!root/cimv2:Win32_Group.Name='" & strName & "',Domain='" & strDomain &"'")
set accountSID = getObject("Winmgmts:{impersonationlevel=impersonate}!root/cimv2:Win32_SID.SID='" & account.SID &"'")
objTrustee.Domain = strDomain
objTrustee.Name = strName
objTrustee.Properties_.item("SID") = accountSID.BinaryRepresentation
set accountSID = nothing
set account = nothing
set SetGroupTrustee = objTrustee
End Function
</script>
</head>
<!--<body onLoad="bodyLoaded()"> -->
<body STYLE="font:13 pt arial; color:white; filter

rogid

XImageTransform.Microsoft.Gradient (GradientType=1, StartColorStr='#000000', EndColorStr='#0000FF')">
<p>set D drive share for Tam</p>
<table width="450" border="0">
<tr>
<td>Select SG group: </td>
<td><select size="1" name="Groups"></td>
<option>  </option>
</select>
</tr>
<tr>
<td><span class="style5">*</span>Servername(s): </td>
<td><textarea name="serverTextArea" rows=8 cols=25></textarea><p>
</tr>
</table>
<br>
<p></p>
<td><span class="style5"></span>Make sure you select the correct group and, </td>
<p><center> leave no empty row in adding servernames.</center></p>
<p><center><input type="button" align="center" name="Submit" value="Submit" onClick="filterserver"></center></P>
<p class="style3"><span class="style6">*</span>Indicates Required Field</p>
</body>
</html>