Jul 13, 2023
How to View a Batch File's Contents on Windows 11
Suspicious about a batch file? Check its contents before you run it on Windows 11. Executing commands in Command Prompt or PowerShell is common on Windows. But sometimes you need to execute a series
Suspicious about a batch file? Check its contents before you run it on Windows 11.
Executing commands in Command Prompt or PowerShell is common on Windows. But sometimes you need to execute a series of commands at once. Using a batch file instead of typing all the commands and executing them one by one is a sensible choice in such cases. You may have downloaded batch files to fix a problem on Windows.
But how to know what the batch file actually contains? Running a batch file without checking its contents is an unsafe approach. Here’s how to preview the batch file contents before running it on your system.
A Batch File is a script file that contains a series of commands to be executed linearly. Once you run the batch file, it will automatically execute the commands and keep on doing so until it reaches the end of the file. After that, it may close the Command Prompt or PowerShell windows and even close an application or restart your system to apply the changes.
But blindly running a batch file can be risky – especially if your grant administrator privileges to run it. So, you must check its contents and compare it with the source, or search for what change the commands can make on your system.
Now that you know what a batch file is, you can use any of the following methods to preview its contents.
Windows File Explorer has had a preview option for a long time. With newer updates, you can now preview files using the Preview pane. It supports text, image, PDF, and a few other file formats. Repeat the following steps to preview a batch file in File Explorer:
Windows Notepad comes pre-packaged with Windows OS, so you don’t need to install it. After recent updates, Notepad supports tabs and can open multiple text files in one window. Repeat the following steps to preview a batch file in Notepad:
Command Prompt can run commands and also view and modify the contents of a file. You can preview any text file without opening the batch file in another program. Moreover, you can use the more and type commands in Command Prompt to do so. Retrace the following steps:
If you want to open the batch file in PowerShell, you can use the get-content cmdlet to preview it. The commands mentioned in the previous methods will also work with PowerShell. Here’s how to do it:
PowerToys recently introduced a Registry Preview feature to open and modify .reg files. Now, it also includes a “Peek” feature that can preview the contents of numerous file formats (image, text, video) and more. Make sure to update the PowerToys to the latest version using the Microsoft Store or download the latest version from GitHub. After that, repeat the following steps:
Every user has more than one web browser installed on their Windows PC and Chrome is surely on the list. You can preview PDFs and text files in Chrome or in any other browser. Repeat the following steps:
Previewing batch files should be a habit to safeguard your Windows PC. You can use the Preview pane, or Notepad to check the contents of the batch file. If you use PowerToys on Windows, you can use the Peek feature. Lastly, even a web browser can help you inspect a batch file.
Abhishek has loved computers ever since he got his hands on the Lenovo G570. He holds a master's degree in computer appliciations and loves writing how-to articles, listicles, and informational posts on Windows, Android, and Internet. When he is not writing anything, he is busy watching new episodes of One Piece or searching for something binge-worthy.
Win + EView Show Preview paneWin + RRun dialog boxNotepad Enter File > Open Ctrl + OFile typeAll files (*.*)Click Open more type Win + E File ExplorerCopy as pathmore more "D:\me.bat"Enter type type "D:\me.bat"Close get-content Ctrl + Shift + CWin + RPowerShell Enter get-content “file path”Enter get-content "D:\me.bat"Peek toggle Enable Peek edit Activation shortcutCtrl + Shift + SpaceSave Minimize Win + EPress Copy Win + Rchrome Ctrl + T Paste double-quotes (“)Enter