Fake Edge App: A PowerShell Script to Create a Web App Shortcut
Table of Contents
Fake Edge App: A PowerShell Script to Create a Fake PWA App #
In today’s digital world, quick and easy access to specific websites can be incredibly useful. One way to achieve this is by creating a Progressive Web App in Microsoft Edge. However this does not work for every site. For Example Microsoft Forms.
In this blog post, I show you a PowerShell script that does just that: it creates a desktop shortcut that opens a specific webpage in a “Fake” Edge App window.
Overview of the Script #
The script we present here creates a desktop shortcut that opens a specific URL in an Edge window. The window is configured to look like a standalone application, which can be particularly useful for frequently accessed web applications.
Script Details #
Here is the complete code of the script:
<#
.Synopsis
Creates a "Fake" Edge App
.INPUTS
Change $websiteURL, $shortcutPath, $logFile, $icoPath, $icoDestinationPath
.OUTPUTS
$logFile Path Transcript
#>
# URL
$websiteURL = "google.de"
# Get the path to the Public Desktop folder using the special folder identifier
$publicDesktopPath = [System.Environment]::GetFolderPath('CommonDesktopDirectory')
# Define the path to the shortcut
$shortcutPath = Join-Path -Path $publicDesktopPath -ChildPath 'NameOfLink.lnk'
# Remove Old lnk if it exists (For Link Updates with same Link name.)
if (Test-Path -Path $shortcutPath) {
Remove-Item -Path $shortcutPath -Force
Write-Output "Old shortcut removed: $shortcutPath"
} else {
Write-Output "No existing shortcut found at: $shortcutPath"
}
# Drop an icon with the .ico extention in the same directory the script will run from.
# Define the source and destination paths
$icoPath = "NameOfLink.ico"
$icoDestinationPath = "$env:ProgramFiles\Samily\Icons\NameOfLink.ico"
# Create the destination directory if it does not exist
$destinationDir = [System.IO.Path]::GetDirectoryName($icoDestinationPath)
if (-not (Test-Path -Path $destinationDir)) {
New-Item -ItemType Directory -Force -Path $destinationDir
}
# Copy the file to the destination
Copy-Item -Path $icoPath -Destination $icoDestinationPath -Force
# Verify the file was copied
if (Test-Path -Path $icoDestinationPath) {
Write-Output "File copied successfully to $icoDestinationPath"
} else {
Write-Output "Failed to copy the file."
}
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$shortcutPath")
$Shortcut.TargetPath = "%SystemDrive%\Windows\System32\cmd.exe"
$Shortcut.Arguments = "/C start `"`" /min `"%SystemDrive%\Program Files (x86)\Microsoft\Edge\Application\msedge.exe`" --app=$($websiteURL) --start-windowed"
$Shortcut.IconLocation = "$icoDestinationPath"
$Shortcut.Save()
How the Script Works #
The script performs the following steps:
- URL Definition: The URL of the webpage to be opened is stored in the
$websiteURL
variable. - Desktop Path: The path to the public desktop folder is obtained.
- Shortcut Path: The path where the shortcut will be created is defined.
- Remove Old Shortcut: If a shortcut with the same name already exists, it is removed.
- Copy Icon File: An icon file is copied to the destination directory.
- Create Shortcut: A new shortcut is created that opens the defined URL in an Edge window.
Customization Options #
The script can be easily customized by changing the following variables:
$websiteURL
: The URL of the webpage to be opened.$shortcutPath
: The path where the shortcut will be created.$logFile
: The path to the log file.$icoPath
and$icoDestinationPath
: Paths to the icon file.
Conclusion #
This PowerShell script provides a simple way to create a desktop shortcut that opens a webpage in a “Fake” Edge App window. It is particularly useful for users who frequently access specific web applications and want seamless integration into their desktop environment. With a few adjustments, the script can be easily tailored to individual needs.
And best of it: It can be installed as an .intuneWin App.