bsharath
asked on
Remove any user or group in the share and add everyone full access to all shares in the machine.
Hi,
Remove any user or group in the share and add everyone full access to all shares in the machine.
I want each share in the machine to have the share permissions as full access for everyone.
Can this be done with a script and have a log on sucess and failures.
I have 300 + shares to do this.
Regards
Sharath
Remove any user or group in the share and add everyone full access to all shares in the machine.
I want each share in the machine to have the share permissions as full access for everyone.
Can this be done with a script and have a log on sucess and failures.
I have 300 + shares to do this.
Regards
Sharath
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
AT what is the time at your place. Just for info...
Where are you from ?
Where are you from ?
3am. I need to get to sleep. I was trying to work out the sizing from the other post.
ASKER
Ok thanks Good night...
ASKER
AT should i run the script for each share. Say if there are 10 shares need to run it 10 times?
ASKER
AT should i run the script for each share. Say if there are 10 shares need to run it 10 times?
Per server. Every share on that server will get modified.
ASKER
Does "RMTSHARE.EXE" work fine with Windows 2000 Server?
As When i just double click the bat file it just gets one share done.
As When i just double click the bat file it just gets one share done.
ASKER
Does "RMTSHARE.EXE" work fine with Windows 2000 Server?
As When i just double click the bat file it just gets one share done.
As When i just double click the bat file it just gets one share done.
ASKER
I get this
G:\>rmtshare \\nas01\"!Share!" | FIND /i "\Everyone : FULL CONTROL"
\Everyone : FULL CONTROL
G:\>IF ERRORLEVEL 1 (
ECHO "\\nas01\!Share!","Everyon e is not set to FULL CONTROL" 1>>G:\nas01-ShareEveryOne. csv
IF Defined Attempt (ECHO "\\nas01\!Share!","Failed to set Everyone to
FULL CONTROL" 1>>G:\nas01-ShareEveryOne. csv ) ELSE (
ECHO "\\nas01\!Share!","Attempt ing to set Everyone to FULL CONTROL" 1>>
G:\nas01-ShareEveryOne.csv
Set Attempt=Trying
rmtshare \\nas01\"!Share!" /GRANT Everyone:F
GOTO CheckEveryone
)
) ELSE (
IF Defined Attempt (ECHO "\\nas01\!Share!","Success fully set Everyone t
o FULL CONTROL" 1>>G:\nas01-ShareEveryOne. csv ) ELSE (ECHO "\\dev-chen
-nas01\!Share!","Everyone is set to FULL CONTROL" 1>>G:\nas01-ShareEver
yOne.csv )
FOR /F "Tokens=1,2 delims=: " %b in ('rmtshare \\NAS01\"!Share!" | FIN
D /i " : " | FIND /v /i "\Everyone"') DO (
ECHO "\\nas01\!Share!","Attempt ing to remove %b %c" 1>>G:\nas0
1-ShareEveryOne.csv
rmtshare \\NAS01\"!Share!" /REMOVE %b
rmtshare \\NAS01\"!Share!" | FIND /i "%b"
IF ERRORLEVEL 1 (ECHO "\\nas01\!Share!","Success fully to removed %b %c
" 1>>G:\nas01-ShareEveryOne. csv ) ELSE (ECHO "\\nas01\!Share!
","Failed to remove %b %c" 1>>G:\nas01-ShareEveryOne. csv )
)
)
G:\>rmtshare \\nas01\"!Share!" | FIND /i "\Everyone : FULL CONTROL"
\Everyone : FULL CONTROL
G:\>IF ERRORLEVEL 1 (
ECHO "\\nas01\!Share!","Everyon
IF Defined Attempt (ECHO "\\nas01\!Share!","Failed to set Everyone to
FULL CONTROL" 1>>G:\nas01-ShareEveryOne.
ECHO "\\nas01\!Share!","Attempt
G:\nas01-ShareEveryOne.csv
Set Attempt=Trying
rmtshare \\nas01\"!Share!" /GRANT Everyone:F
GOTO CheckEveryone
)
) ELSE (
IF Defined Attempt (ECHO "\\nas01\!Share!","Success
o FULL CONTROL" 1>>G:\nas01-ShareEveryOne.
-nas01\!Share!","Everyone is set to FULL CONTROL" 1>>G:\nas01-ShareEver
yOne.csv )
FOR /F "Tokens=1,2 delims=: " %b in ('rmtshare \\NAS01\"!Share!" | FIN
D /i " : " | FIND /v /i "\Everyone"') DO (
ECHO "\\nas01\!Share!","Attempt
1-ShareEveryOne.csv
rmtshare \\NAS01\"!Share!" /REMOVE %b
rmtshare \\NAS01\"!Share!" | FIND /i "%b"
IF ERRORLEVEL 1 (ECHO "\\nas01\!Share!","Success
" 1>>G:\nas01-ShareEveryOne.
","Failed to remove %b %c" 1>>G:\nas01-ShareEveryOne.
)
)
ASKER
I get this
G:\>rmtshare \\nas01\"!Share!" | FIND /i "\Everyone : FULL CONTROL"
\Everyone : FULL CONTROL
G:\>IF ERRORLEVEL 1 (
ECHO "\\nas01\!Share!","Everyon e is not set to FULL CONTROL" 1>>G:\nas01-ShareEveryOne. csv
IF Defined Attempt (ECHO "\\nas01\!Share!","Failed to set Everyone to
FULL CONTROL" 1>>G:\nas01-ShareEveryOne. csv ) ELSE (
ECHO "\\nas01\!Share!","Attempt ing to set Everyone to FULL CONTROL" 1>>
G:\nas01-ShareEveryOne.csv
Set Attempt=Trying
rmtshare \\nas01\"!Share!" /GRANT Everyone:F
GOTO CheckEveryone
)
) ELSE (
IF Defined Attempt (ECHO "\\nas01\!Share!","Success fully set Everyone t
o FULL CONTROL" 1>>G:\nas01-ShareEveryOne. csv ) ELSE (ECHO "\\dev-chen
-nas01\!Share!","Everyone is set to FULL CONTROL" 1>>G:\nas01-ShareEver
yOne.csv )
FOR /F "Tokens=1,2 delims=: " %b in ('rmtshare \\NAS01\"!Share!" | FIN
D /i " : " | FIND /v /i "\Everyone"') DO (
ECHO "\\nas01\!Share!","Attempt ing to remove %b %c" 1>>G:\nas0
1-ShareEveryOne.csv
rmtshare \\NAS01\"!Share!" /REMOVE %b
rmtshare \\NAS01\"!Share!" | FIND /i "%b"
IF ERRORLEVEL 1 (ECHO "\\nas01\!Share!","Success fully to removed %b %c
" 1>>G:\nas01-ShareEveryOne. csv ) ELSE (ECHO "\\nas01\!Share!
","Failed to remove %b %c" 1>>G:\nas01-ShareEveryOne. csv )
)
)
G:\>rmtshare \\nas01\"!Share!" | FIND /i "\Everyone : FULL CONTROL"
\Everyone : FULL CONTROL
G:\>IF ERRORLEVEL 1 (
ECHO "\\nas01\!Share!","Everyon
IF Defined Attempt (ECHO "\\nas01\!Share!","Failed to set Everyone to
FULL CONTROL" 1>>G:\nas01-ShareEveryOne.
ECHO "\\nas01\!Share!","Attempt
G:\nas01-ShareEveryOne.csv
Set Attempt=Trying
rmtshare \\nas01\"!Share!" /GRANT Everyone:F
GOTO CheckEveryone
)
) ELSE (
IF Defined Attempt (ECHO "\\nas01\!Share!","Success
o FULL CONTROL" 1>>G:\nas01-ShareEveryOne.
-nas01\!Share!","Everyone is set to FULL CONTROL" 1>>G:\nas01-ShareEver
yOne.csv )
FOR /F "Tokens=1,2 delims=: " %b in ('rmtshare \\NAS01\"!Share!" | FIN
D /i " : " | FIND /v /i "\Everyone"') DO (
ECHO "\\nas01\!Share!","Attempt
1-ShareEveryOne.csv
rmtshare \\NAS01\"!Share!" /REMOVE %b
rmtshare \\NAS01\"!Share!" | FIND /i "%b"
IF ERRORLEVEL 1 (ECHO "\\nas01\!Share!","Success
" 1>>G:\nas01-ShareEveryOne.
","Failed to remove %b %c" 1>>G:\nas01-ShareEveryOne.
)
)
Try this one instead.
The GOTO wasn't working for more than 1 change at a time.
Also the removing of groups did not remove if the group name had a space like Domain Users.
The GOTO wasn't working for more than 1 change at a time.
Also the removing of groups did not remove if the group name had a space like Domain Users.
SETLOCAL ENABLEDELAYEDEXPANSION
Set Comp=%1
IF "%Comp%" == "" Set Comp=%ComputerName%
Set ShareEveryone=C:\%Comp%-ShareEveryOne.csv
for /f "tokens=1 delims=:" %%a in ('rmtshare \\%Comp%^| find /v /i "default share" ^| find /v /i "Remote admin" ^| find /v /i "Remote IPC" ^| FIND ":"') DO (
set Share=%%a
set Share=!Share:~0,-2!
For /l %%z in (1,1,30) DO if "!Share:~-1!" == " " Set Share=!Share:~0,-1!
Set Attempt=
CALL :CHECKEVERYONE "!Share!"
)
:CheckEveryone
IF "%~1" == "" GOTO :EOF
rmtshare \\%Comp%\"%~1" | FIND /i "\Everyone : FULL CONTROL"
IF ERRORLEVEL 1 (
ECHO "\\%Comp%\%~1","Everyone is not set to FULL CONTROL">>%ShareEveryone%
IF Defined Attempt (
ECHO "\\%Comp%\%~1","Failed to set Everyone to FULL CONTROL">>%ShareEveryone%
) ELSE (
ECHO "\\%Comp%\%~1","Attempting to set Everyone to FULL CONTROL">>%ShareEveryone%
Set Attempt=Trying
rmtshare \\%Comp%\"%~1" /GRANT Everyone:F
CALL :CHECKEVERYONE "%~1"
)
) ELSE (
IF Defined Attempt (
ECHO "\\%Comp%\%~1","Successfully set Everyone to FULL CONTROL">>%ShareEveryone%
) ELSE (
ECHO "\\%Comp%\%~1","Everyone is set to FULL CONTROL">>%ShareEveryone%
)
FOR /f "Tokens=1,2 delims=:" %%b in ('rmtshare \\%ComputerName%\"%~1" ^| FIND /i ": " ^| FIND /v /i "\Everyone"') DO (
Set Group=%%b
For /l %%z in (1,1,30) DO if "!Group:~-1!" == " " Set Group=!Group:~0,-1!
For /l %%z in (1,1,30) DO if "!Group:~0,1!" == " " Set Group=!Group:~1!
ECHO "\\%Comp%\%~1","Attempting to remove !Group! %%c">>%ShareEveryone%
rmtshare \\%ComputerName%\"%~1" /REMOVE "!Group!"
rmtshare \\%ComputerName%\"%~1" | FIND /i "!Group!"
IF ERRORLEVEL 1 (
ECHO "\\%Comp%\%~1","Successfully to removed !Group! %%c">>%ShareEveryone%
) ELSE (
ECHO "\\%Comp%\%~1","Failed to remove !Group! %%c">>%ShareEveryone%
)
)
)
ASKER
Thank U Works fine here but on my Nas shall check and let you know...
Any help with the other posts
Any help with the other posts
ASKER
And reporting is Awesome...