Generally to get the meta data from SQL Server backup files, we need to use TSQL commands like
restore headeronly or
restore filelistonly. However, there are some third party tools can read this information directly from the backup files, like this one <a href="http://www.yohz.com/sqlbakreader_details.htm" rel="nofollow">http://www.yohz.com/sqlbakreader_details.htm</a>. Since this tool don't have a command line version, which makes it less useful. I want to know whether there are some ways that I can read this data directly.
The .bak file is a Microsoft Tape Format file. Here's a <a href="http://laytongraphics.com/mtf/MTF_100a.PDF" rel="nofollow">PDF</a> that contains the format.
Of interest to you will be:
<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/zLKNF.png" data-original="https://i.stack.imgur.com/zLKNF.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />
For a quick dump (if you are on the SQL Server in question that created the backup), you can do select from the [msdb].[dbo].[backup*] tables.
See this <a href="http://www.mssqltips.com/sqlservertip/1601/script-to-retrieve-sql-server-database-backup-history-and-no-backups/" rel="nofollow">article</a> for more info.Answer2:
I think you may be able to use SQL Servers SMO libraries and write your own in .net or Powershell. If you take a look at this page <a href="http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.readbackupheader.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.readbackupheader.aspx</a> there are code samples in VB.Net and Powershell.