Wednesday, November 28, 2012

Command Prompt : Command " attrib "

ATTRIB.exe

Display or change file attributes. Find Filenames.
Syntax
      ATTRIB [ + attribute | - attribute ] [pathname] [/S [/D]]

Key
     +    : Turn an attribute ON
     -    : Clear an attribute OFF

 pathname : Drive and/or filename e.g. C:\*.txt
    /S    : Search the pathname including all subfolders.
    /D    : Process folders as well

   attributes: 

        R  Read-only (1)
        H  Hidden (2)
        A  Archive (32)
        S  System (4)

   extended attributes:
        E  Encrypted
        C  Compressed (128:read-only)
        I  Not content-indexed
        L  Symbolic link/Junction (64:read-only)
        N  Normal (0: cannot be used for file selection)
        O  Offline
        P  Sparse file
        T  Temporary 
The numeric values may be used when changing attributes with VBS/WSH
If no attribute is specified attrib will return the current attribute settings. Used with just the /S option ATTRIB will quickly search for a particular filename.

Hidden and System attributes take priority.


If a file has both the Hidden and System attributes set, you can clear both attributes only with a single ATTRIB command.

For example, to clear the Hidden and System attributes for the RECORD.TXT file, you would type:
ATTRIB -S -H RECORD.TXT

File Attributes

You can use wildcards (? and *) with the filename parameter to display or change the attributes for a group of files.

Remember that, if a file has the System or Hidden attribute set, you must clear that attribute before you can change any other attributes.

Directory Attributes

You can display or change the attributes for a directory/folder. To use ATTRIB with a directory, you must explicitly specify the directory name; you cannot use wildcards to work with directories.
For example, to hide the directory C:\SECRET, you would type the following:

ATTRIB +H C:\SECRET

The following command would affect only files, not directories: ATTRIB +H C:*.*
The Read-only attribute for a folder is generally ignored by applications, however the Read-only and System attributes are used by Windows Explorer to determine whether the folder is a special folder, such as My Documents, Favorites, Fonts, etc.
Setting the Read-Only attribute on a folder can affect performance, particularly on shared drives because Windows Explorer will be forced to request the Desktop.ini of every sub-folder to see if any special folder settings need to be set.

Viewing archive attributes

The Archive attribute (A) is used to mark files that have changed since they were previously backed up. The (A) flag is automatically updated by Windows as the file is saved.

If the (A) flag is present - the file is new or has been changed since the last backup.

The MSBACKUP, RESTORE, and XCOPY commands use these Archive attributes, as do many (but not all) 3rd party backup solutions.
Extended Attributes
File attributes can be read with fsutil usn readdata filename.ext
Constants - the following attribute values are returned by the GetFileAttributes function:
FILE_ATTRIBUTE_READONLY = 1 (0x1)
FILE_ATTRIBUTE_HIDDEN = 2 (0x2)
FILE_ATTRIBUTE_SYSTEM = 4 (0x4)
FILE_ATTRIBUTE_DIRECTORY = 16 (0x10)
FILE_ATTRIBUTE_ARCHIVE = 32 (0x20)
FILE_ATTRIBUTE_NORMAL = 128 (0x80)
FILE_ATTRIBUTE_TEMPORARY = 256 (0x100)
FILE_ATTRIBUTE_SPARSE_FILE = 512 (0x200)
FILE_ATTRIBUTE_REPARSE_POINT = 1024 (0x400)
FILE_ATTRIBUTE_COMPRESSED = 2048 (0x800)
FILE_ATTRIBUTE_OFFLINE = 4096 (0x1000)
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192 (0x2000)
FILE_ATTRIBUTE_ENCRYPTED = 16384 (0x4000)
For example, a file attribute of 0x120 indicates the Temporary + Archive attributes are set (0x100 + 0x20 = 0x120.)
DFSR will not replicate files if they have the temporary attribute set.
The temporary attribute can be removed by using PowerShell to subtract 0x100:
PS C:\> Get-childitem D:\Data -recurse | ForEach-Object -process {if (($_.attributes -band 0x100) -eq 0x100) {$_.attributes = ($_.attributes -band 0xFEFF)}}
"The moral sense of conscience is by far the most important.. it is the most noble of all the attributes of man" - Charles Darwin

@reference site : http://ss64.com/nt/attrib.html

Tuesday, August 14, 2012

Java_code : month showing


import java.util.Scanner;
public class month_show {

/**
* @param args
*/
public static void check_name_of_month(int mon){
System.out.println("=======================================================");
System.out.print("\t\t\t");
switch(mon){
case 1:System.out.println("January");break;
case 2:System.out.println("Febulary");break;
case 3:System.out.println("March");break;
case 4:System.out.println("April");break;
case 5:System.out.println("May");break;
case 6:System.out.println("June");break;
case 7:System.out.println("July");break;
case 8:System.out.println("August");break;
case 9:System.out.println("September");break;
case 10:System.out.println("Octorber");break;
case 11:System.out.println("November");break;
case 12:System.out.println("December");break;
default:System.out.print("");
}
System.out.println("=======================================================");
}
public static int count_month(int mon){
int day ;
check_name_of_month(mon);
if ( mon == 2)
day = 28;
else if (mon > 7 && mon <= 12)
if (mon%2==0)
day = 31;
else
day = 30;
else if (mon < 8 && mon > 0)
if (mon%2==0)
day = 30;
else
day = 31;
else
day = 0;
return day;
}
public static void show_month(int mon){
int day = count_month(mon);
if (day == 0){
System.out.println("INCORRECT MONTH(1-12)");
}else{
System.out.print("Sun\t");
System.out.print("Mon\t");
System.out.print("Tue\t");
System.out.print("Wed\t");
System.out.print("Thur\t");
System.out.print("Fri\t");
System.out.println("Sat\t");
int con_day ;
for (int i=1 ;i<=day;i++){
System.out.print(i+"\t");
con_day = i%7;
if(con_day==0)
System.out.println("");
}
System.out.println("\n=======================================================");
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.print("Month:");
int day = sc.nextInt();
show_month(day);
}

}