MSFN Forum: Ms DOS attrib command - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ms DOS attrib command Rate Topic: -----

#1 User is offline   kingprageeth 

  • Newbie
  • Group: Members
  • Posts: 20
  • Joined: 21-August 07

Posted 22 August 2007 - 09:14 PM

I'm new for DOS.I want to change the attribute of all the folders in my USB flash drive as System Folders. But I don't want to change the attribute of the files inside those folders. Can somebody tell me a command for that. :(


#2 User is offline   Sfor 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 512
  • Joined: 01-July 07
  • OS:98SE
  • Country: Country Flag

Posted 23 August 2007 - 12:16 AM

SYS command can not change attributes of folders. It works with file attributes, only.

In general dos is not able to change attributes of folders, such a possibility came with the Windows GUI. Still, the system attribute of a folder requires disk editor, or some other special application.

In order to get a folder with a system attribute set without additional application, the simplest solution would be to make a copy of some other system folder. Luckily, Explorer is able to change a system folder name.

#3 User is offline   kingprageeth 

  • Newbie
  • Group: Members
  • Posts: 20
  • Joined: 21-August 07

  Posted 23 August 2007 - 04:03 AM

Attribute of folders can be changed using command prompt. Ex:- the command "attrib +s +h d:\myfolder" will change the attribute of "myfolder". The command "attrib +s +h d:\myfolder\*.* /s /d" will change the attribute of all the files and sub folders in "myfolder". But I want to change the attribute of folders only. Please help me. :(

#4 User is offline   Sfor 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 512
  • Joined: 01-July 07
  • OS:98SE
  • Country: Country Flag

Posted 23 August 2007 - 04:46 AM

Interesting, it does work, indeed.

It is not possible to change multiple folders arrtibutes with a single command. The DOS does not process folders with wildard based operations. It is necesary to run a separate command for every folder.

It is possible to do it in Windows 2000/NT system. But this will require a small batch program.

In case of a Windows 9x system a VB script could do it, I think.

#5 User is offline   Mijzelf 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 447
  • Joined: 11-April 07

Posted 23 August 2007 - 04:47 AM

/D does 'process folders as well'

So
attrib +s d:\myfolder\*.* /s /d
attrib -s d:\myfolder\*.* /s
should set the system flag for all folders, and reset it for all files.

#6 User is offline   Sfor 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 512
  • Joined: 01-July 07
  • OS:98SE
  • Country: Country Flag

Posted 23 August 2007 - 04:55 AM

View PostMijzelf, on Aug 23 2007, 12:47 PM, said:

/D does 'process folders as well'

So
attrib +s d:\myfolder\*.* /s /d
attrib -s d:\myfolder\*.* /s
should set the system flag for all folders, and reset it for all files.


With Windows 2000, yes. With Windows 98, no.

The /d switch is not supported in Windows 9x.

#7 User is offline   Mijzelf 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 447
  • Joined: 11-April 07

Posted 23 August 2007 - 05:28 AM

Ah, I see.

It's not dos, but next code should work:
var system = 4;
var hidden = 2;

function DoFolder( folder )
{
	var fso = new ActiveXObject("Scripting.FileSystemObject");	
	f = fso.GetFolder(folder);
	f.attributes  |= system;
	f.attributes  |= hidden;

	var fc = new Enumerator( f.SubFolders );

	for (; !fc.atEnd(); fc.moveNext() )
   	{
		DoFolder( fc.item() );
   	}
}

DoFolder( "D:\\MyFolder" );

Copy the code, save it as a .js file, and doubleclick on it. It should set the system and hidden attribute of all subfolders of D:\MyFolder, including MyFolder itself. Have a look at the double \ in "D:\\MyFolder". This is necessary for all backslashes in your path.

#8 User is offline   kingprageeth 

  • Newbie
  • Group: Members
  • Posts: 20
  • Joined: 21-August 07

  Posted 23 August 2007 - 06:45 AM

Ooooooh my dear friend Mijzelf, your script is a magic and that was what i was needed. please tell me the way of unhide the folders.Thanx again and again my friend.... :thumbup

#9 User is offline   Mijzelf 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 447
  • Joined: 11-April 07

Posted 24 August 2007 - 01:43 AM

Quote

please tell me the way of unhide the folders

The line

f.attributes |= hidden;

should be changed to

f.attributes &= ~hidden;

which removes the hidden flag.

Other possible flags are:
1 ReadOnly
2 Hidden
4 System
8 Disk drive volume label. Attribute is read-only.
16 Directory. Attribute is read-only.
32 Archive
64 Shortcut. Attribute is read-only.
128 Compressed. Attribute is read-only.

#10 User is offline   kingprageeth 

  • Newbie
  • Group: Members
  • Posts: 20
  • Joined: 21-August 07

  Posted 29 August 2007 - 05:04 AM

Thank u very much for helping me Mijzelf. My problem is ok. Thankx again... :whistle:

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy