2015-01-26 43 views
1

無論如何要搜索一般意義上的命令提示符參數。還是我們挾持這些程序的文檔?例如在命令提示符下,我輸入explorer或notepad ...但是如果我把第一個參數作爲文件路徑,它會爲我打開該文件路徑...我怎麼知道這個參數輸入存在,也許有我不知道的一堆其他參數字段。無論如何要系統地搜索程序參數?搜索命令提示符參數?

回答

1

在Windows中,程序負責處理他們自己的命令行參數,並且他們可以以任何他們喜歡的方式進行操作。 (通常將標記化處理交給C運行時庫,但不是強制性的。)

這給了程序員最大的靈活性,但確實意味着如果程序員沒有記錄命令行,則沒有直接的方法來反向事後處理它。 (UNIX並沒有太大的不同;標記化是由shell來處理的,但其餘的處理是應用程序的責任;而在VMS中,相比之下,整個命令行處理由shell處理,基於必須被嵌入在應用程序的語法信息)

它是常規的用於應用程序響應於一個或多個以下選項提供命令行語法總結:

application /? 
application -? 
application /help 
application -help 
application --? 
application --help 

(大致從最常見到最不常見的安排;帶有兩個連字符的變體通常只能在sof中找到已經從UNIX移植tware。)

我沒有看過實際的統計數據,但我的印象是,大多數的命令行應用程序(可能是80%或更多)也提供了這樣的總結。 GUI應用程序不太常見。

如果做不到這一點,你有時可以通過尋找可執行文件中的字符串find命令行選項。微軟提供了一個實用工具,可以從他們的網站下載這個工具,strings.exe。 (當然,知道一個可能的命令行選項的存在並不一定意味着你能夠弄清楚它的功能!)

如果你有權訪問源代碼,或者擅長反彙編如果你足夠絕望,這可能會提供另一種選擇。

+0

鏈接到strings.exe https://technet.microsoft.com/zh-cn/sysinternals/bb897439.aspx – CodeCamper 2015-03-21 05:03:52

1

不,儘管您可以隨時嘗試programname /?

記事本只需要一個單一的文件名或採取/p filename ...(你可以看到在註冊表txtfiles打印項命令)。

這裏的東西從Windows 98 Explorer的它仍然是一樣的。

Explorer 
explorer [/n] [/e][,/root,object][[,/select],subobject] 

None Explorer rooted at the Desktop 
/n Opens a new window. 
/e Explorer View (default if nothing else is on the command line.) 
/root,object Starts Explorer with object the top item (normally Desktop is the top item). Eg: explorer /e,/root,c:\Starts Explorer with the C drive as the only drive available. 
/select,subobject Selects the specified subobject. 

Replaceable parameters are %1 (one) which is the short file or folder name and %l (L) which is the long file name. 

/IDLIST 
This is an additional parameter that means a Windows internal structure is being passed. eg: 

Explorer.exe /e,/idlist,%I 
The %I is a replacable parameter representing an IDLIST. 

Rooted Views 
To open an explorer item that starts with a special folder as the top folder use the following syntax. 

Where the special folder is a sub folder of the desktop 

explorer /e,root,::{CLSID of special folder} 

Where the special folder is a sub folder of another special folder (usually, if not always My Computer) 

explorer /e,root,::{CLSID of parent}/::{CLSID of special folder} 

Where the special folder is part of the file system 

explorer /e,root,path to folder 

See Namespaces on the Icons Page for a list of CLSIDs for special folders. 

Examples 
Note that /select is inconsistent. Sometime the/is required, sometimes it should be left out, and sometimes it doesn't matter. 

Starts explorer with the Windows folder opened and selected. 

explorer /e,select,c:\windows 
Starts explorer with Windows the top level folder and command opened and selected. 

explorer /e,/root,c:\windows,select,c:\windows\command 
Starts explorer with Windows the top level folder and Tips.txt showing instead of the file listing. 

explorer /e,/root,c:\windows,select,c:\windows\tips.txt 
Starts explorer with My Computer the top level folder and all branches except for drives collapsed. 

explorer /e,/root,::{20d04fe0-3aea-1069-a2d8-08002b30309d} 
Starts explorer with C:\ the top level folder. 

explorer /e,/root,c:\ 
Starts the Dial Up Networking folder in folder view. 

explorer.exe ::{20d04fe0-3aea-1069-a2d8-08002b30309d}\::{992cffa0-f557-101a-88ec-00dd010ccc48}