?
Solved

Script to change file permissions on multiple servers?

Posted on 2009-04-16
9
Medium Priority
?
621 Views
Last Modified: 2012-05-06
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!
0
Comment
Question by:BobbySams
  • 4
  • 3
  • 2
9 Comments
 

Expert Comment

by:iranmatrix
ID: 24157632
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
0
 

Expert Comment

by:iranmatrix
ID: 24157674
for read only use code above :)
0
 

Author Comment

by:BobbySams
ID: 24157732
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!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 38

Accepted Solution

by:
Shift-3 earned 2000 total points
ID: 24157776
It's slightly more complicated, as you'll need PsExec to execute the commands remotely and you need to revoke access before setting back to read-only.  See below for examples.


REM Script to grant Write access
@echo off
setlocal
 
set file=c:\program files\Windows NT\Accessories\ mswrd8.wpc
 
psexec @computerlist.txt cacls "%file%" /E /G Everyone:W
 
 
REM Script to change access back to Read
@echo off
setlocal
 
set file=c:\program files\Windows NT\Accessories\ mswrd8.wpc
 
psexec @computerlist.txt cacls "%file%" /E /R Everyone
psexec @computerlist.txt cacls "%file%" /E /G Everyone:R

Open in new window

0
 
LVL 38

Expert Comment

by:Shift-3
ID: 24157801
Oh, and remove the extra space before the filename.

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

Open in new window

0
 

Author Comment

by:BobbySams
ID: 24157973
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?
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 24158098
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?
0
 

Author Comment

by:BobbySams
ID: 24158460
ah HA! I am having one of those days. I didn't have psexec.exe in the same dir. Works now, like magic. THANKS!!
0
 

Author Closing Comment

by:BobbySams
ID: 31570979
Thanks very much!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question