当前位置:网站首页>[batch dos-cmd command - summary and summary] - view or modify file attributes (attrib), view and modify file association types (Assoc, ftype)

[batch dos-cmd command - summary and summary] - view or modify file attributes (attrib), view and modify file association types (Assoc, ftype)

2022-07-07 00:57:00 dssgresadfsrgre

One 、 View or modify file properties ——ATTRIB

Execute the order first 【attrib /?】, See help information .

C:\Users\Administrator>attrib /?
 Show or change file properties .

ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [+O | -O] [+I | -I] [+X | -X] [+P | -P] [+U | -U]
       [drive:][path][filename] [/S [/D]] [/L]

  +    Set properties .
  -    Clear properties .
  R    Read only file properties .
  A    Archive properties .
  S    System file properties .
  H    Hide file properties .
  O    Offline properties .
  I    No content index file properties .
  X    No clean file properties .
  V    Integrity properties .
  P    Fixed attribute .
  U    Non fixed attributes .
  [drive:][path][filename]
       Specify the properties of the file to process .
  /S   Process the current folder and all its subfolders 
       Matching files for .
  /D   Also handle folders .
  /L   Handling symbolic links and 
       Properties of the symbolic link target 


C:\Users\Administrator>

example :

md autorun
attrib +a +s +h autorun

The above command will create a folder autorun, Then set it to archive 、 System 、 Hidden attribute

Two 、 View the file types associated with modifying file extensions ——assoc

2.1 Show command assoc Help for

Print assoc Help for , Carry out orders 【assoc /?】.

C:\Users\Administrator>assoc /?
 Show or modify file extension associations 

ASSOC [.ext[=[fileType]]]

  .ext       Specifies the file extension associated with the file type 
  fileType   Specifies the file type associated with the file extension 

 type  ASSOC  Without parameters , Displays the current file association . If you only use file extensions 
 Call  ASSOC, The current file association of that file extension is displayed . If not for 
 The file type specifies any parameters , The command deletes the association of file extensions .

C:\Users\Administrator>

2.2 Display the file types corresponding to all extensions  

Execute the command without any parameters 【assoc】, Get the file types corresponding to all extensions , As shown below ( Only excerpts ).

C:\Users\Administrator>assoc
.3ds=Photoshop.3DSFileType.140
.3gp=WMP11.AssocFile.3GP
.AAC=WMP11.AssocFile.ADTS
.abr=Photoshop.BrushesFile
.csv=Excel.CSV
.dat=xmp.dat
.db=ANSYS 2020 R2 .db File
.doc=Word.Document.8
.dll=dllfile
.mp3=WMP11.AssocFile.MP3
.mp4=WMP11.AssocFile.MP4
.mpeg=WMP11.AssocFile.MPEG
.png=pngfile
.txt=txtfile
.xml=xmlfile

2.3 Displays the file type corresponding to the specified file extension  

Execute the command with the extension parameter 【assoc .ext】, The file type corresponding to the extension will be displayed .

For example, to perform 【assoc .exe】, The return is 【.exe=exefile】, explain .exe The corresponding file type is exefile.

in addition .txt The file type of is txtfile, and .doc The file type of is Word.Document.8.

assoc .txt        # Show .txt Representative ' file type ', Results show .txt=txtfile
assoc .doc      # Show .doc Representative ' file type ', Results show .doc=Word.Document.8

3、 ... and 、 View the program associated with modifying the file extension ——ftype

3.1 View command ftype Help for

Execute the order first 【ftype /?】, View help information .

C:\Users\Administrator>ftype /?
 Displays or modifies the file types used in file extension associations 

FTYPE [fileType[=[openCommandString]]]

  fileType   Specify the file type to check or change 
  openCommandString  Specify the open commands to use when calling such files .

 type  FTYPE  Without parameters to display the currently defined open command string 
 file type .FTYPE  When enabled with only one file type , It shows which file class 
 Type current open command string . If you do not specify ,
FTYPE  Command will delete the open command string of that file type . In a 
 Within the open command string , Command string  %0  or  %1  Called by Association 
 Instead of the file name of .%*  Get all the parameters ,%2  Get the first parameter ,
%3  Get a second , wait .%~n  Get all the rest with  nth  Parameters begin 
 Parameters ;n  It can be from  2  To  9  The number of . for example :

    ASSOC .pl=PerlScript
    FTYPE PerlScript=perl.exe %1 %*

 Allows you to enable the following  Perl  Script :

    script.pl 1 2 3

 If you do not want to type an extension , Then type the following string :

    set PATHEXT=.pl;%PATHEXT%

 The script that is started is as follows :

    script 1 2 3

C:\Users\Administrator>

3.2 Check the startup program corresponding to all file types

Execute without parameters ftype command , give the result as follows ( Incomplete ).

C:\Users\Administrator>ftype

Excel.CSV="D:\Program Files\Microsoft Office\Office16\EXCEL.EXE" /dde
Folder=%SystemRoot%\Explorer.exe
http="C:\Program Files\Internet Explorer\iexplore.exe" %1
https="C:\Program Files\Internet Explorer\iexplore.exe" %1
kugou="D:\Program Files (x86)\KuGou\KGMusic\KuGou.exe" "%1"
Python.ArchiveFile="C:\WINDOWS\py.exe" "%L" %*
Python.CompiledFile="C:\WINDOWS\py.exe" "%L" %*
Python.File="C:\WINDOWS\py.exe" "%L" %*
Python.NoConArchiveFile="C:\WINDOWS\pyw.exe" "%L" %*
Python.NoConFile="C:\WINDOWS\pyw.exe" "%L" %*
WinRAR="D:\Program Files\WinRAR\WinRAR.exe" "%1"
WinRAR.REV="D:\Program Files\WinRAR\WinRAR.exe" "%1"
WinRAR.ZIP="D:\Program Files\WinRAR\WinRAR.exe" "%1"

3.3 Check the startup program corresponding to the specified file type

Rule of grammar .

ftype filetype   #  There is no need to add a dot before the file type string 

Carry out orders 【ftype exefile】, The result is 【exefile="%1" %*】.

Carry out orders 【ftype txtfile】, The result is 【txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1】.

3.4 Modify the startup program corresponding to the specified file type

  Rule of grammar .

ftype filetype=openCommandString   #  There is no need to add a dot before the file type string 

Ordinary users generally do not use this rule , Because the startup program string is too difficult to understand .

For the average user , The frequently used operation is nothing more than associating a certain extension with a certain file type , such as doc And word Application relevance , This is not necessary ftype Ordered , Use a command directly 【assoc .doc=Word.Document.8】 that will do .

3、 ... and 、windows The system opens the file process


When you double click on one .txt When you file ,windows Not based on .txt For direct judgment notepad.exe open .

But first by order 【assoc .txt】 The results of the implementation of 【.txt=txtfile】 Judge to know .txt Belong to txtfile file type ,

Call again txtfile Associated command line , That is to say 【txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1】 Corresponding program .

Four 、windows Restore file associations

4.1 except exe Program , Restore the association directly with the command

for example , It's on command 【assoc .txt=Word.Document.8】, Yes txt After the extension file changes the file type , To restore the original Association , You can use the command 【assoc .txt=txtfile】

4.2 about exe Program , Restoring associations requires .com

exe File is windows Executable files in the system , The file association determines the way the file is opened .

When we accidentally change exe After program association ,cmd The program cannot be opened normally .

How to recover correctly exe File Association ?

First, in the C:\WINDOWS\system32(64 position WOW64) In the directory cmd.exe, Select the file and press F2 key , Change the file name to cmd.com.

Then double click to execute cmd.com, Pop up command line window , Enter the command 【assoc .exe=exefile】 And return .

原网站

版权声明
本文为[dssgresadfsrgre]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207061701191838.html