Include error: c:\sites\trogsoft.com\includes\auth.smi does not exist.

Deploying Shortcuts, Files and Folders using Group Policy

Using Group Policy, it is entirely possible to deploy shortcuts, files and folders, as well as drive mappings, ini files, registry settings and environment variables. This article will take a look at the items on that list specifically related to the filesystem - shortcuts, files, folders and drive mappings.

Files

Group Policy allows you to deploy files and create folders on computers you are managing without having to visit those PCs manually. You can do this either in Computer Configuration or User Configuration, but we are going to be using User Configuration.

To begin, open Group Policy Editor, and navigate to User Configuration\Preferences\Files, right click on Files and choose New\File.

Create New FileCreate New File

The fields you can fill in are as follows:

Action Create - Create a file the next time the policy is applied.
Remove - Remove a named file the next time the policy is applied.
Replace - Delete and recreate a named file when the policy is next applied. Create if the file doesn't exist.
Update - Modify an existing named file when the policy is next apllied. Create if the file doesn't exist.
Source File(s)The source file, or files, you wish to copy when the policy is applied
Destination FileThe destination file, or folder, to which you wish to copy the file(s).

This a fairly simple dialog - all you need to do is choose a source file, or files, and enter a destination file, or directory (in the case of multiple source files), and choose what file attributes you wish the new files to have. To demonstrate how this works, consider the screenshot above, then consider what you see on the screenshot below. What we are attempting to do here is copy some fictional XML configuration file from a network loation to the application folder of some fictional application, in effect distributing the entire program's configuration using Group Policy. You could, for example, do this for programs such as Firefox, which have no Group Policy awareness.

Created New FileCreated New File

As you can see, Group Policy did all the hard work here. Because "Some Application" is a fictional application which didn't actually exist on the disk, Group Policy has created the folder structure for us.

Folders

Deploying Folders works in much the same way, but you have many more options for when the folder is deleted.

Create New FolderNew Folder

If you wish to create a folder, it works in the same way as creating Files, detailed above. You simply choose the Action (usually Update), and enter a complete folder path which will be created when the policy is next applied. You can set attributes on the folder as you could with the New File dialog.

When you choose the Delete or Replace option for Action, as shown above, you get access to 5 additional options which determine how a folder structure will be deleted (before being replaced, if Replace is the option you have chosen for Action).

Delete this folder (if emptied)Deletes the folder only if it's empty
Recursively delete all subfolders (if emptied)Deletes any and all subfolders inside the folder, if they are empty.
Delete all files in the folder(s)Deletes files inside the root folder, but not subfolders, unless 'Recursively delete all subfolders' is also selected.
Allow deletion of read only/hidden files/foldersCauses read only and hidden files/folders to be deleted.
Ignore errors for files/folders that cannot be deletedHides error messages from the user which relate to the deletion of files or folders.

Shortcuts

You can create shortcuts in the Computer or User section of any Group Policy Object. Creating shortcuts in a Computer policy causes the shortcut to appear to be created whenever anyone logs on to the computer to which the policy applies. Creating shortcuts in a User policy means that the shortcuts are created when a user logs on to whom the policy applies. Additional conditions may take effect depending on where you want the shortcut to appear.

First, open the Group Policy Object (GPO) you wish to edit in Group Policy manager, and navigate to User Configuration \Preferences\Shortcuts. Right click on Shortcuts, and choose New\Shortcut.

Create New ShortcutCreate New Shortcut

The fields in the New Shortcut window are as follows

Action Create - Create a shortcut the next time the policy is applied.
Remove - Remove a named shortcut the next time the policy is applied.
Replace - Delete and recreate a named shortcut when the policy is next applied. Create if the shortcut doesn't exist.
Update - Modify an existing named shortcut when the policy is next apllied. Create if the shortcut doesn't exist.
NameThe shortcut name as the user sees it
Target TypeWhat is the shortcut targetting? Your options are a Filesystem Object (file or folder), a URL (website address), or a Shell Object (printer, share, computer, network resource)
LocationWhere should the shortcut be created? Your options are to specify a path, or to choose a pre-defined path, such as the Desktop or Start Menu. If you are specifying a full path, you must place the full path, including shortcut name, in the 'Name' box
Target Path/URL/ObjectThe path to the object (file, folder, URL, etc) you are creating a shortcut to.
ArgumentsThis option is only valid for a Target Type of File System Object, and should contain any parameters you wish to pass to the file your shortcut points to.
Start InThis option is only valid for a Target Type of File System Object, and should contain the path you wish to be the 'Current Directory' when the shortcut is double clicked by a user.
Shortcut KeyThis option allows you to specify a hotkey that will launch the shortcut when the user presses it.
RunSpecifies the default window size for the launched file, folder or shell object (not valid for URLs).
CommentA comment for the shortcut
Icon File PathThe path to an icon file, or a file containing icons.
Icon IndexThe icon index in the event that the previous field is a file containing many icons.

To demonstrate the workings of this feature, we'll create a URL shortcut which we'll place on the desktop for all users, which will link to a company project tracking system. We have filled in the New Shortcut window as shown below.

Create New ShortcutCreate New Shortcut

Because we've created this shortcut in the User Configuration section of the policy, simply logging on to the computer verifies that the shortcut has been created successfully.

New Shortcut CreatedNew Shortcut Created