Jump to content

Recommended Posts

Posted

Hi

I'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


Posted

wouldn't using the attrib command in a batch file work?

attrib

Displays 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.

Posted

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.

Posted (edited)
I'm not sure how you're copying but if you use XCOPY instead of COPY

I'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 by rikgale
Posted

Here Is A VBS Script To Reset The attributes

Change The Green To Match Your Needs

Const READ_ONLY = 1

Dim 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 Code

Set 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_ONLY

Next

Posted

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.cmd

GSM, 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.....

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...