Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add shortcut to desktop using group policy

Status
Not open for further replies.

jfc1003

IS-IT--Management
Joined
May 2, 2002
Messages
146
Location
US
How do I add a shortcut pointing to a network share on to everybody's desktop using group policy or scripts? I need some details.

Thanks before hand for any help.
 
I only know of 4 icons that can be controlled by group policy, but hopefully the following code can put you on the right track.

Copy and paste the code below into a file named shortcut.js. The name is unimportant, but it must have the file extention js. The code creates the notepad icon on the desktop. It will run by double clicking on it, or it can be a stand-alone login script, or part of a batch file.

If you have any programming background you can easily modify the code to suit your needs. Good Luck.

Joe Miles


// Windows Script Host Sample Script
//
// ------------------------------------------------------------------------
// Copyright (C) 1996-1997 Microsoft Corporation
//
// You have a royalty-free right to use, modify, reproduce and distribute
// the Sample Application Files (and/or any modified version) in any way
// you find useful, provided that you agree that Microsoft has no warranty,
// obligations or liability for any Sample Application Files.
// ------------------------------------------------------------------------


// This sample demonstrates how to use the WSHShell object to create a shortcut
// on the desktop.
var vbOKCancel = 1;
var vbInformation = 64;
var vbCancel = 2;

var L_Welcome_MsgBox_Message_Text = "This script will create a shortcut to Notepad on your desktop.";
var L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample";
Welcome();

// ********************************************************************************
// *
// * Shortcut related methods.
// *

var WSHShell = WScript.CreateObject("WScript.Shell");


// Read desktop path using WshSpecialFolders object
var DesktopPath = WSHShell.SpecialFolders("Desktop");

// Create a shortcut object on the desktop
var MyShortcut = WSHShell.CreateShortcut(DesktopPath + "\\Shortcut to notepad.lnk");

// Set shortcut object properties and save it
MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("%windir%\\notepad.exe");
MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("%windir%");
MyShortcut.WindowStyle = 4;
MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("%windir%\\notepad.exe, 0");
MyShortcut.Save();

WScript.Echo("A shortcut to Notepad now exists on your Desktop.");

//////////////////////////////////////////////////////////////////////////////////
//
// Welcome
//
function Welcome() {
var WSHShell = WScript.CreateObject("WScript.Shell");
var intDoIt;

intDoIt = WSHShell.Popup(L_Welcome_MsgBox_Message_Text,
0,
L_Welcome_MsgBox_Title_Text,
vbOKCancel + vbInformation );
if (intDoIt == vbCancel) {
WScript.Quit();
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top