How to get n script check a folder permission and sharing?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
akal
Posts: 1
Joined: 18 Jan 2013 00:39

How to get n script check a folder permission and sharing?

#1 Post by akal » 18 Jan 2013 00:44

Anyone got a script that woul go through a specfic path and check if a specify folder has sharing enable or not and also check permission?

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: How to get n script check a folder permission and sharin

#2 Post by abc0502 » 18 Jan 2013 01:17

You can use the NET SHARE Command, it will be faster as it has all shared folders and files, also it contain each file/folder location in your PC.

I don't know about the permissions but this batch should give you a list of all shared resources along with there names.

Code: Select all

@Echo Off

For /F "skip=5 tokens=1* delims= " %%A in ('NET SHARE') Do (
   Echo.
   IF NOT "%%B" == "command completed successfully." (
      Echo  Shared Resources : %%B
      Echo  Share Name : %%A
   )
)   
pause

If you want to check specific directory add IF command to compare the location you want so it display it if it exist.

shirulkar
Posts: 40
Joined: 15 Jan 2013 23:53

Re: How to get n script check a folder permission and sharin

#3 Post by shirulkar » 21 Jan 2013 03:32

Hi,

To check sharing enable or disable you can use NET Share command.

and to check the write permission, following will work


copy /Y NUL "%YourFolder%\.writable" > NUL 2>&1 && set WRITEOK=1

IF DEFINED WRITEOK (Echo ---- we have write access ----) else (Echo ---- we don't ----)

Post Reply