rikgale Posted August 20, 2005 Share Posted August 20, 2005 HiI'm trying to figure how to set the attributes of a file after it has been copied from within the $OEM$ dir. after the installation?Background: I am using Stickies5.2a, and copying it over from within $Progs folder. The settings and the stickies themselves are stores in an .ini file in Users\Appilcation Data\Stickies. I copied my current .ini file to $OEM$\$Docs\Default User\Application Data\Stickies, and it installs and runs fine. However when I shutdown the machine it cannot save the updated stickies or any new stickies that I have created because the .ini file is set as read only as it has been copied from the CD.I could manually set this after every install, but is there a way of doing it UA. I've had a quick search about but not come up with anything useful. Any help gratefully appreciated.Ta Rik Link to comment Share on other sites More sharing options...
jbm Posted August 20, 2005 Share Posted August 20, 2005 wouldn't using the attrib command in a batch file work?attribDisplays or changes file attributes.ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [drive:][path][filename] [/s [/D]] + Sets an attribute. - Clears an attribute. R Read-only file attribute. A Archive file attribute. S System file attribute. H Hidden file attribute. [drive:][path][filename] Specifies a file or files for attrib to process. /S Processes matching files in the current folder and all subfolders. /D Processes folders as well. Link to comment Share on other sites More sharing options...
rikgale Posted August 20, 2005 Author Share Posted August 20, 2005 That's what I am looking for. I'm now off to find an example to wortk with.Thanx Link to comment Share on other sites More sharing options...
Yzöwl Posted August 20, 2005 Share Posted August 20, 2005 I'm not sure how you're copying but if you use XCOPY instead of COPY xcopy /?it will reset read-only attributes if you don't use the /K switch. Link to comment Share on other sites More sharing options...
rikgale Posted August 20, 2005 Author Share Posted August 20, 2005 (edited) I'm not sure how you're copying but if you use XCOPY instead of COPYI've been dumping it in the $Docs folder off $OEM$ so windows copies it over itself. I'm just running a test install in VMWare as I type using the attrib cmd Edited August 20, 2005 by rikgale Link to comment Share on other sites More sharing options...
gunsmokingman Posted August 20, 2005 Share Posted August 20, 2005 Here Is A VBS Script To Reset The attributesChange The Green To Match Your NeedsConst READ_ONLY = 1Dim Act : Set Act = CreateObject("Wscript.Shell")Dim SD : SD = = Act.ExpandEnvironmentStrings("%Systemdrive%")strComputer = "."Set objFSO = CreateObject("Scripting.FileSystemObject")Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") '' Oringinal Code From Hey Script Guys I Have Modified It So it Starts In %systemDrive% '' Set colFiles = objWMIService. _ '' ExecQuery("Select * from CIM_DataFile where Path = '\\Scripts\\' " & _ '' "AND Drive = 'C:' AND Writeable = FALSE")'''' My Modified CodeSet colFiles = objWMIService. _ ExecQuery("Select * from CIM_DataFile where Path = '\\Scripts\\' " & _ "AND Drive = ''" & SD & "'"' AND Writeable = FALSE")For Each objFile in colFiles Set objReadOnlyFile = objFSO.GetFile(objFile.Name) objReadOnlyFile.Attributes = objReadOnlyFile.Attributes XOR READ_ONLYNext Link to comment Share on other sites More sharing options...
rikgale Posted August 20, 2005 Author Share Posted August 20, 2005 I went with sticking this IF EXIST "%UserProfile%\Application Data\stickies\stickies.ini" attrib -r "%UserProfile%\Application Data\stickies\stickies.ini"IF EXIST "%systemdrive%\Documents and Settings\Default User\Application Data\stickies\stickies.ini" attrib -r "%systemdrive%\Documents and Settings\Default User\Application Data\stickies\stickies.ini"in my cleanup.cmdGSM, thanx for the vbs code, but I'm not sure what to change the green too. I think I'll stick with the above for the time being. Thanx all..... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now