M
Mary
Hi all! Is there a way to delete all shared folders in a folder at once? I
didn't see a way to use wildcards with Net Share. Thanks
didn't see a way to use wildcards with Net Share. Thanks
Mary said:Hi all! Is there a way to delete all shared folders in a folder at once? I
didn't see a way to use wildcards with Net Share. Thanks
Herb Martin said:Mary said:Hi all! Is there a way to delete all shared folders in a folder at once?
I
didn't see a way to use wildcards with Net Share. Thanks
Just so we are clear (the term 'folder' is largely ambiguous): You
do mean to delete the share points not the underlying files?
If so, the following will give you a start (it's all one line and if you
put it in a batch file you must DOUBLE the two reference to %a,
i.e., %%a):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %a in (ttt.tmp) do
@echo net share /d %a
Note for safety:
This does NOT actually delete the shares but only
writes the commands to do that -- run it, review the output,
decide if you need more "exception /C:" commands, or
redirect the output to a text file, edit it and run as a batch.
Version for a batch file (again all on one line):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %%a in (ttt.tmp) do
@echo net share /d %%a
(I purposely didn't use the /I case insentive switch but you
don't have to follow that if you prefer to simplify.)
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Mary said:Thanks, Herb. You're right about the word folder! What I want to do is
delete about 2000 student folders and their contents. All of the folders are
shared; so I'd like to run a program that will remove the shares and delete
the contents. Thanks!
Herb Martin said:Mary said:Hi all! Is there a way to delete all shared folders in a folder at once?
I
didn't see a way to use wildcards with Net Share. Thanks
Just so we are clear (the term 'folder' is largely ambiguous): You
do mean to delete the share points not the underlying files?
If so, the following will give you a start (it's all one line and if you
put it in a batch file you must DOUBLE the two reference to %a,
i.e., %%a):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %a in (ttt.tmp) do
@echo net share /d %a
Note for safety:
This does NOT actually delete the shares but only
writes the commands to do that -- run it, review the output,
decide if you need more "exception /C:" commands, or
redirect the output to a text file, edit it and run as a batch.
Version for a batch file (again all on one line):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %%a in (ttt.tmp) do
@echo net share /d %%a
(I purposely didn't use the /I case insentive switch but you
don't have to follow that if you prefer to simplify.)
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Herb Martin said:Mary said:Thanks, Herb. You're right about the word folder! What I want to do is
delete about 2000 student folders and their contents. All of the folders are
shared; so I'd like to run a program that will remove the shares and delete
the contents. Thanks!
Ok, well the contents are in the "rest" of the line but you may have to
deal with "spaces" in the directory names.
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server"
/C:"Remote IPC" /C:"Remote Admin"
/C:"The command" /C:SYSVOL /C:spool > ttt.tmp
&& for /f "tokens=1-2" %a in (ttt.tmp) do
@echo net share /d %a && @echo rd /s /q "%b"
The above is the echo (print) version of a VERY dangerous command
since it will del /q (quiet - no ask) a directory and all files and
subdirectories thereunder.
It assumes no spaces in the file name -- and would require work to
overcome that limitation.
Also it might be easier IF you place most of the directories in the
same parent directory AND wish to delete all of them (or can move
any you wish to keep). Just go to the parent and after taking a very
deep breath (and a backup) type:
rd /s /q C:\theParentOfTheSharedDirectories
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Herb Martin said:Hi all! Is there a way to delete all shared folders in a folder at once?
I
didn't see a way to use wildcards with Net Share. Thanks
Just so we are clear (the term 'folder' is largely ambiguous): You
do mean to delete the share points not the underlying files?
If so, the following will give you a start (it's all one line and if
you
put it in a batch file you must DOUBLE the two reference to %a,
i.e., %%a):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %a in (ttt.tmp) do
@echo net share /d %a
Note for safety:
This does NOT actually delete the shares but only
writes the commands to do that -- run it, review the output,
decide if you need more "exception /C:" commands, or
redirect the output to a text file, edit it and run as a batch.
Version for a batch file (again all on one line):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %%a in (ttt.tmp) do
@echo net share /d %%a
(I purposely didn't use the /I case insentive switch but you
don't have to follow that if you prefer to simplify.)
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Mary said:Thanks so much! Yes, deleting the parent directory will work just fine.
Thanks again!
Mary
Herb Martin said:Mary said:Thanks, Herb. You're right about the word folder! What I want to do is
delete about 2000 student folders and their contents. All of the folders are
shared; so I'd like to run a program that will remove the shares and delete
the contents. Thanks!
Ok, well the contents are in the "rest" of the line but you may have to
deal with "spaces" in the directory names.
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server"
/C:"Remote IPC" /C:"Remote Admin"
/C:"The command" /C:SYSVOL /C:spool > ttt.tmp
&& for /f "tokens=1-2" %a in (ttt.tmp) do
@echo net share /d %a && @echo rd /s /q "%b"
The above is the echo (print) version of a VERY dangerous command
since it will del /q (quiet - no ask) a directory and all files and
subdirectories thereunder.
It assumes no spaces in the file name -- and would require work to
overcome that limitation.
Also it might be easier IF you place most of the directories in the
same parent directory AND wish to delete all of them (or can move
any you wish to keep). Just go to the parent and after taking a very
deep breath (and a backup) type:
rd /s /q C:\theParentOfTheSharedDirectories
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Hi all! Is there a way to delete all shared folders in a folder at once?
I
didn't see a way to use wildcards with Net Share. Thanks
Just so we are clear (the term 'folder' is largely ambiguous): You
do mean to delete the share points not the underlying files?
If so, the following will give you a start (it's all one line and if
you
put it in a batch file you must DOUBLE the two reference to %a,
i.e., %%a):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %a in (ttt.tmp) do
@echo net share /d %a
Note for safety:
This does NOT actually delete the shares but only
writes the commands to do that -- run it, review the output,
decide if you need more "exception /C:" commands, or
redirect the output to a text file, edit it and run as a batch.
Version for a batch file (again all on one line):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %%a in (ttt.tmp) do
@echo net share /d %%a
(I purposely didn't use the /I case insentive switch but you
don't have to follow that if you prefer to simplify.)
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Mary said:Well, half of my problem is solved. The folders are gone, but the shares
(most of them are hidden) are still there in Computer Management, Shares.
How can I delete those all at once?
Thanks,
Mary
Mary said:Thanks so much! Yes, deleting the parent directory will work just fine.
Thanks again!
Mary
Herb Martin said:Thanks, Herb. You're right about the word folder! What I want to do is
delete about 2000 student folders and their contents. All of the folders
are
shared; so I'd like to run a program that will remove the shares and
delete
the contents. Thanks!
Ok, well the contents are in the "rest" of the line but you may have to
deal with "spaces" in the directory names.
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server"
/C:"Remote IPC" /C:"Remote Admin"
/C:"The command" /C:SYSVOL /C:spool > ttt.tmp
&& for /f "tokens=1-2" %a in (ttt.tmp) do
@echo net share /d %a && @echo rd /s /q "%b"
The above is the echo (print) version of a VERY dangerous command
since it will del /q (quiet - no ask) a directory and all files and
subdirectories thereunder.
It assumes no spaces in the file name -- and would require work to
overcome that limitation.
Also it might be easier IF you place most of the directories in the
same parent directory AND wish to delete all of them (or can move
any you wish to keep). Just go to the parent and after taking a very
deep breath (and a backup) type:
rd /s /q C:\theParentOfTheSharedDirectories
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Hi all! Is there a way to delete all shared folders in a folder at
once?
I
didn't see a way to use wildcards with Net Share. Thanks
Just so we are clear (the term 'folder' is largely ambiguous): You
do mean to delete the share points not the underlying files?
If so, the following will give you a start (it's all one line and if
you
put it in a batch file you must DOUBLE the two reference to %a,
i.e., %%a):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %a in (ttt.tmp) do
@echo net share /d %a
Note for safety:
This does NOT actually delete the shares but only
writes the commands to do that -- run it, review the output,
decide if you need more "exception /C:" commands, or
redirect the output to a text file, edit it and run as a batch.
Version for a batch file (again all on one line):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %%a in (ttt.tmp) do
@echo net share /d %%a
(I purposely didn't use the /I case insentive switch but you
don't have to follow that if you prefer to simplify.)
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Herb Martin said:Mary said:Well, half of my problem is solved. The folders are gone, but the shares
(most of them are hidden) are still there in Computer Management, Shares.
How can I delete those all at once?
Using the script line (or a variation) that I gave you in the first
response.
Run it on the Server which provides the shares -- they are NOT hidden
there when you use "net share" (they are only hidden from other machines).
I purposely use "Default share" when filtering to avoid using the "$"
which
might end ANY hidden share.
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Thanks,
Mary
Mary said:Thanks so much! Yes, deleting the parent directory will work just fine.
Thanks again!
Mary
Thanks, Herb. You're right about the word folder! What I want to do
is
delete about 2000 student folders and their contents. All of the folders
are
shared; so I'd like to run a program that will remove the shares and
delete
the contents. Thanks!
Ok, well the contents are in the "rest" of the line but you may have
to
deal with "spaces" in the directory names.
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server"
/C:"Remote IPC" /C:"Remote Admin"
/C:"The command" /C:SYSVOL /C:spool > ttt.tmp
&& for /f "tokens=1-2" %a in (ttt.tmp) do
@echo net share /d %a && @echo rd /s /q "%b"
The above is the echo (print) version of a VERY dangerous command
since it will del /q (quiet - no ask) a directory and all files and
subdirectories thereunder.
It assumes no spaces in the file name -- and would require work to
overcome that limitation.
Also it might be easier IF you place most of the directories in the
same parent directory AND wish to delete all of them (or can move
any you wish to keep). Just go to the parent and after taking a very
deep breath (and a backup) type:
rd /s /q C:\theParentOfTheSharedDirectories
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]
Hi all! Is there a way to delete all shared folders in a folder at
once?
I
didn't see a way to use wildcards with Net Share. Thanks
Just so we are clear (the term 'folder' is largely ambiguous): You
do mean to delete the share points not the underlying files?
If so, the following will give you a start (it's all one line and
if
you
put it in a batch file you must DOUBLE the two reference to %a,
i.e., %%a):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %a in (ttt.tmp) do
@echo net share /d %a
Note for safety:
This does NOT actually delete the shares but only
writes the commands to do that -- run it, review the output,
decide if you need more "exception /C:" commands, or
redirect the output to a text file, edit it and run as a batch.
Version for a batch file (again all on one line):
net share | findstr /V /C:"--" /C:"Share name" /C:Spool
/C:"Default share" /C:"Logon server" /C:"Remote IPC"
/C:"Remote Admin" /C:"The command" /C:SYSVOL
/C:spool > ttt.tmp && for /f %%a in (ttt.tmp) do
@echo net share /d %%a
(I purposely didn't use the /I case insentive switch but you
don't have to follow that if you prefer to simplify.)
--
Herb Martin, MCSE, MVP
Accelerated MCSE
http://www.LearnQuick.Com
[phone number on web site]