Link to home
Start Free TrialLog in
Avatar of BobbySams
BobbySams

asked on

Script to change file permissions on multiple servers?

Good Day-

We are having issues applying KB923561 to our servers. If I change c:\program files\Windows NT\Accessories\ mswrd8.wpc to give the EVERYONE group read/write access, the update applies.

I'd like to do a script that will apply these permissions to all the servers I specify in a txt file, then another script to change it back to read only. Can someone help?

Thank you!
Avatar of iranmatrix
iranmatrix
Flag of United Arab Emirates image

Hi,
use

CACLS "c:\program files\Windows NT\Accessories\ mswrd8.wpc"  /P EVERYONE:F
for full access and
CACLS "c:\program files\Windows NT\Accessories\ mswrd8.wpc" /P EVERYONE:R
for read only use code above :)
Avatar of BobbySams
BobbySams

ASKER

I must be doing something wrong.
I created a txt file called computerlist.txt. I put one server name in there to test.

then, I created a file called RW_everyone.cmd. In this file I put:
@echo off
setlocal enabledelayedexpansion
set list=computerlist.txt
CACLS "c:\program files\Windows NT\Accessories\mswrd8.wpc"  /P EVERYONE:F

The file permissions did not change. What am I doing wrong?

Thanks for your help!
ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh, and remove the extra space before the filename.

set file=c:\program files\Windows NT\Accessories\mswrd8.wpc

Open in new window

Shift-3, thank you. I'm still having problems for some reason.

In computerlist.txt I have a single computer name, still. Tried with FQDN and without.
In the cmd file, I have:

@echo off
setlocal
 
set file=c:\program files\Windows NT\Accessories\mswrd8.wpc
 
psexec @computerlist.txt cacls "%file%" /E /G Everyone:W

Still not changing. I do have domain admin rights, and the domain admin group has local admin rights on each server. I also tried running the script against my local computer with no success. Thoughts?
Is computerlist.txt located in the same directory as the script?

Is psexec.exe located in the same directory as the script or somewhere in the system path?

What errors are coming up?
ah HA! I am having one of those days. I didn't have psexec.exe in the same dir. Works now, like magic. THANKS!!
Thanks very much!