Category filter

Script to Create a New Folder and Add Shortcut on Windows

Saving too many files on your desktop may slow down the system and make it harder to organize files. In addition, files on the desktop are not as secure as the files in libraries like ‘My Documents’ when you use System Restore or run file-based backup programs. Therefore, it is recommended to create shortcuts on your desktop as a quick way to access files stored on your hard drive. With Hexnode, IT admins can seamlessly execute custom scripts remotely on Windows devices.


The Sample Scripts provided below are adapted from third-party Open-Source sites.

PowerShell Script

This PowerShell code sets the target for a shortcut called “ShortcutName.lnk” to ” C:\EpicFolder” and saves it to the Desktop.

$path – Environment variable where applications look for executables which means it can make or break a system or utility installation.

New-Item – Creates files and folders.

ItemType– Parameter specifies that the new item is a directory, not a file or other file system object.

Force -Parameter lets you create a file in the profile path, even when the directories in the path do not exist.

New-Object creates the object and sets each property value and invokes each method.

ComObject, or plain COM, increases the range of PowerShell activities.

WScript.Shell– Creates an object that is an instance of the Windows shell, allowing you to run commands against the Windows shell.

WshShell is a generic name for a powerful object that enables you to query and interact with various aspects of the Windows shell.


  • The latest version of the Hexnode Agent app should be installed on the device.
  • 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.

  • Sample Script Repository