Computer Hope

Microsoft => Microsoft Windows => Windows XP => Topic started by: tutsuo on February 02, 2009, 02:08:46 AM

Title: Batch File setting Attributes
Post by: tutsuo on February 02, 2009, 02:08:46 AM
I'm not sure iv asked this correctly before because others never give the right answer(Even Google couldn't find it LOL).

I'm wondering if a batch file can change the attribute(Read-only, Hidden and, Archive) of a file, and if so what is the command.

I'm trying write a batch file that can set a normal file to a hidden attribute.

This is what i have so far:

" start view.exe /shtml view.html "

Is there a way to add a command so it saves/changes it to a hidden attribute? Or write another batch to would run after that and change it to Hidden attribute.

-Thanks in advance
Tutsuo
Title: Re: Batch File setting Attributes
Post by: Dusty on February 02, 2009, 02:17:09 AM
Welcome to the CH forums.

Use the ATTRIB command to set attributes.  Enter ATTRIB/? in the command line to view parameters.

Good luck
Title: Re: Batch File setting Attributes
Post by: tutsuo on February 02, 2009, 08:28:32 PM
i dont understand... so

" start view.exe /shtml attrib/hidden view.html "

?
Title: Re: Batch File setting Attributes
Post by: Geek-9pm on February 02, 2009, 08:48:12 PM
Quote
start view.exe

Is view a Windows program? It is not in my XP system.
Why would you need to make the file hidden? If it is in a system area the average user is not going to see it. And if he is a super user he will find it anyway.
Title: Re: Batch File setting Attributes
Post by: tutsuo on February 02, 2009, 09:17:32 PM
the program is run from a usb flash drive. . .
Title: Re: Batch File setting Attributes
Post by: Dusty on February 03, 2009, 12:31:52 AM
I don't understand either....  Here are the parameters (switches) for the Attrib command...
Quote
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.


To hide a file use

ATTRIB +H DRIVE\PATH\FILENAME   

Example:
attrib +h f:\view.exe

or

attrib +h f:\idontknow\whodoes.exe


Title: Re: Batch File setting Attributes
Post by: tutsuo on February 05, 2009, 11:45:35 AM
Hmm ill try that out.