# Script to Clear Browsing History on Windows devices

In institutions such as hotels, hospitals, and schools, the devices may be shared among multiple users. In such instances, other users may gain access to the users’ internet surfing history. Hence, organizations may require to delete the browsing history from the devices to protect the privacy of each user. However, manually clearing browsing history from every device will be a cumbersome process. Hexnode lets you remotely do this on Windows devices by [executing custom scripts](https://www.hexnode.com/mobile-device-management/help/executing-custom-scripts-for-windows/) from the portal.

 Note: 
**Supported Versions**:

The scripts given below will be supported on the following versions:

- Windows 10 v1607+ (Pro, Enterprise, Education)
- Windows 11 (Pro, Enterprise, Education)

 

 Disclaimer:The sample scripts provided below are adapted from third-party open-source sites.

 

Batch script
------------

**1) Clear browsing history of Google Chrome**

Batch script to clear browsing history of Google Chrome

del /q /s /f “C:\\Users\\Username\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History” 

   1

  del /q /s /f “C:\\Users\\Username\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History” 

   

 

  

Replace **“Username”** with actual username.

**2) Clear browsing history of Microsoft Edge**

Batch script to clear browsing history of Microsoft Edge

@echo off :: Kill Edge if running taskkill /IM msedge.exe /F >nul 2>&1 set Folder=C:\\Users\\%USERNAME%\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default if exist "%Folder%\\History" ( del /q /s /f "%Folder%\\History" echo Edge browsing history cleared successfully ) else ( echo Edge history file not found )

   1

2

3

4

5

6

7

8

9

10

11

12

  @echo off

:: Kill Edge if running

taskkill /IM msedge.exe /F >nul 2>&1

set Folder=C:\\Users\\%USERNAME%\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default

if exist "%Folder%\\History" (

 del /q /s /f "%Folder%\\History"

 echo Edge browsing history cleared successfully

) else (

 echo Edge history file not found

)

   

 

  

![Windows Batch script to delete browsing history of Microsoft Edge returns the output in the Action History tab of Hexnode.](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2022/04/Microsoft-Edge-history-cleared-using-Windows-Batch-script-to-delete-browsing-history--300x149.png)

Replace **%Username%** with actual username.

PowerShell script
-----------------

**1) Clear browsing history of Google Chrome**

PowerShell script to clear browsing history of Google Chrome

$Items = @('Archived History', 'History', 'Top Sites', 'Visited Links') $Folder = "C:\\Users\\Username\\AppData\\Local\\Google\\Chrome\\User Data\\Default" $Items | % { if (Test-Path "$Folder\\$\_") { Remove-Item "$Folder\\$\_" } } 

   1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

  $Items = @('Archived History',

 'History',

 'Top Sites',

 'Visited Links')

$Folder = "C:\\Users\\Username\\AppData\\Local\\Google\\Chrome\\User Data\\Default"

$Items | % {

 if (Test-Path "$Folder\\$\_") {

 Remove-Item "$Folder\\$\_"

 }

} 

   

 

  

Replace “Username” with your username.

**2) Clear browsing history of Microsoft Edge**

PowerShell script to clear browsing history of Microsoft Edge

\# Kill Edge if running Get-Process msedge -ErrorAction SilentlyContinue | ForEach-Object { Stop-Process $\_ -Force } Start-Sleep -Seconds 2 # Define Edge history path for current user $historyPath = "C:\\Users\\USERNAME\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default\\History" if (Test-Path $historyPath) { try { Remove-Item $historyPath -Force Write-Output "Edge browsing history cleared successfully" } catch { Write-Output "Failed to clear Edge browsing history: $\_" } } else { Write-Output "Edge history file not found" }

   1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

  \# Kill Edge if running

Get-Process msedge -ErrorAction SilentlyContinue | ForEach-Object { Stop-Process $\_ -Force }

Start-Sleep -Seconds 2

\# Define Edge history path for current user

$historyPath = "C:\\Users\\USERNAME\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default\\History"

if (Test-Path $historyPath) {

 try {

 Remove-Item $historyPath -Force

 Write-Output "Edge browsing history cleared successfully"

 } catch {

 Write-Output "Failed to clear Edge browsing history: $\_"

 }

} else {

 Write-Output "Edge history file not found"

}

   

 

  

![Windows PowerShell script to delete browsing history of Microsoft Edge returns the output in the Action History tab of Hexnode.](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2022/04/Microsoft-Edge-history-cleared-using-Windows-PowerShell-script-to-delete-browsing-history--300x148.png)

Replace **“Username”** with actual username.

How to View Script Output in Hexnode
------------------------------------

To review the execution results, navigate to the **Action History** tab of the specific device in your Hexnode UEM portal. Locate the script entry in the **Subject** column and click the **Show Output** button next to the status field to view the returned data.

 Notes:- The script works only when the browser is closed.
- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.