Windows 7 Script for change files permissions

#1
Hi, I've a problem with a software that create some files, those Child objects do not inherit permissions from their parent as expected.

To solve this issue I have to manually edit the parent permission and give to his childs the same permissions of the folder itself. The checkbox solud be: Replace all permissions for child objects with inheritable permissions derived from this object
(I use an italian version of seven, so I don't know how this label is in english)

I need to make a script that each x time (1 time a day) run this command.

What should I look for?
I can create a .bat or somthing like this and then shedule it.
Bud I've never did this before, and I don't know how to find the right command

any tips?
 


kaos

Senior Member
#2
Hi
Id need the Full path of the location to the folder, What permission you are wanting , if its full access or deny access , ill wip you something up
 


#3
Hi
Id need the Full path of the location to the folder, What permission you are wanting , if its full access or deny access , ill wip you something up
logged users should read the files
the path is C:\Danea\Archivi

if you can write a script I'd like to read it, and undrstand wat's up.

thanks a lot for help me. :redface:
 


kaos

Senior Member
#4
your more than welcome.

are you wanting read only on the content after "C:\Danea\Archivi/(here)" or full access , read write etc?
 


kaos

Senior Member
#5
if you can write such as

full control (unticked)
write (TICK)
read (TICK)
 


kaos

Senior Member
#7
ok ill work on it now for you
 


kaos

Senior Member
#8
ok these are based on the fact
READ + EXEC
READ
WRITE - DENY
SPECIAL PERMS -DENY

there is no point implying a read only command if not DENY commands arnt set, as you can still write to the files

here is the code used

Code:
@echo off
cls
title File Permissions

echo.
Echo Set File Permisions
echo.
echo Deny write + Read
echo (execute also included as mandatory)
echo.
Echo 1) Apply Read only
echo 2) Reset (Full Control)

set choice= 
set /p choice=Please select your option: 
IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
if '%choice%'=='1' goto enab
if '%choice%'=='2' goto reset



:enab
cls
cacls "C:\Danea\Archivi/*.*" /p %username%:n
echo.
cacls "C:\Danea\Archivi/*.*" /e /g %username%:r
exit


pause

:reset 
cacls "C:\Danea\Archivi/*.*" /e /g %username%:f
pause
copy it into notepad

save it as "anythin you wnt ere".bat

i.e Permissions.bat
or
Fileperms.bat

wat ever
 


#9
ok these are based on the fact
READ + EXEC
READ
WRITE - DENY
SPECIAL PERMS -DENY

there is no point implying a read only command if not DENY commands arnt set, as you can still write to the files
good!

I need to make this script run without any userinput, I should add it to a cron.

I changed it as that:

Code:
@echo offcls
title File Permissions


cls
cacls "C:\Danea Easyfatt\Archivi\Amodio - Allegati\Doc\*.*" /p "Authenticated Users":n
echo.
cacls "C:\Danea Easyfatt\Archivi\Amodio - Allegati\Doc\*.*" /e /g "Authenticated Users":r
exit
But when I run it, it ask for confirmation (Y/N)
 


kaos

Senior Member
#10
It must have user input , The cacls command doesnt have a switch /y command for an auto answer
 


#11
It must have user input , The cacls command doesnt have a switch /y command for an auto answer
ouch!:frown:

is there another way that don't require user input?
 


kaos

Senior Member
#12
Sorted it for you, Took me some time HOWEVER this works

Code:
:enab
cls
echo y| cacls "C:\Danea\Archivi/*.*" /p %username%:n
echo.
echo y| cacls "C:\Danea\Archivi/*.*" /e /g %username%:r
exit

I Have piped the command into the initial command
 


#13
Sorted it for you, Took me some time HOWEVER this works

Code:
:enab
cls
echo y| cacls "C:\Danea\Archivi/*.*" /p %username%:n
echo.
echo y| cacls "C:\Danea\Archivi/*.*" /e /g %username%:r
exit

I Have piped the command into the initial command
perfect!

thanks a lot!!!
 


kaos

Senior Member
#14
your welcome


any more scripts or anything then let me no, we can create loads of different tasks from file hiding to locking etc
 


#15
your welcome


any more scripts or anything then let me no, we can create loads of different tasks from file hiding to locking etc
I'd like to learn how make it by myself, where can I find a reference?
 


kaos

Senior Member
#16
well depends on what you want to acheieve,what you want to show or act etc

id start basic, i would jump in the deep end creating mad stuff. start small... do something write text, then it clears

so basics would be

@echo off (always use this)
cls - clear screen
echo - echos text so to start would be
pause - waits , press any key to continue

@echo off
cls
echo hello
pause

the displays the word hello, and text after the echo
to create space would be

@echo off
cls
echo hello
echo.
echo how are you

this would be like
Code:
Hello

How are you
 


#17
well depends on what you want to acheieve,what you want to show or act etc
Is there a reference with all the possible commands?
 


kaos

Senior Member
#18
Windows CMD Commands

That has a list of commands, applying them into a script maybe a little harder than it looks BUT im here if u need help. Wat was u thinking of creating?
 


#19
Windows CMD Commands

That has a list of commands, applying them into a script maybe a little harder than it looks BUT im here if u need help. Wat was u thinking of creating?
moving files from a source to a destination, something very easy, the list you post is what I'm looking for... thanks for all!
 


kaos

Senior Member
#20
ok this is an example

Code:
@echo off
cls
color A 
set /p f=Files to be moved:
set /p d=Destination :
xcopy %f%" "%d%
pause
so F is basically an open variable meaning that F can be anything i.e a path in our example. the D as our second as our destionation.. once these are set we use the normal command xcopy then outputting what we first specificed which was f and d

you can drag a file onto the cmd window to auto populate the path but on the destination you have to make sure that the path endings with a /
e.g c:/program files/document.txt
to
c:/program files/test folder /
without that the file wont move
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.