Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Using a batch file to create desktop shortcuts

Posted on 2009-05-04
11
3,993 Views
Last Modified: 2012-05-06
I'm using Windows Server 2008 Standard with Windows XP clients.  All clients are on a domain.  I need to create a batch script that will load desktop shortcuts when the user logs in.  I know how to assign the batch file to the OU's but I need help with the batch file creation itself.  Here is the kicker... my shortcuts have a Target path that is different than the Start in path.  Here is an example:

In the shortcut properties...

Target: C:\FamousSoftware\Famous.exe

Start in: Z:\FamousSoftware

so basically the target is for the local computer and the start in is a mapped network drive on the server.  Any help?  
0
Comment
Question by:rbudj
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 1

Expert Comment

by:ConnectNZ
ID: 24300013
How is the batch file creating the shortcuts? Is it copying them from a central location? Surely if they are pre-configured with the Target and Start-in values, they will retain those values once the shortcuts are copied to the users' desktops.
0
 
LVL 7

Expert Comment

by:Valleriani
ID: 24300025
I don't know if this is any help, but check out

http://www.msfn.org/board/index.php?showtopic=29964&hl=creat+shortcut

It uses a inf file to create a shortcut, and looks like you can modify the folder/etc. Uses a cmd file but same thing as a bat file I believe really. If this doesn't help I do apologize! Was looking around for you and it's all I found. It's easy to create a shortcut but the kicker you have there is the issue!
0
 
LVL 16

Author Comment

by:rbudj
ID: 24300154
I have a logon batch file already in place to map a network drive so I have to use this same batch file to create the shortcuts.  Currently there is no script to create the shortcuts.  That is why I am asking here.  I can place the shortcuts in on the server and copy them but I do not know how to create the batch file to do so.
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 1

Accepted Solution

by:
ConnectNZ earned 500 total points
ID: 24300253
Just create a shortcuts.bat (or whatever) file in notepad. make sure you create it with a .bat extension and not a .txt extension.

These commands will copy the shortcuts:

@echo off

copy x:\shortcut1.lnk %userprofile%\Desktop
copy x:\shortcut2.lnk %userprofile%\Desktop

(or you could use *.lnk to copy a bunch of them at once)

Then in your logon script add:

call shortcuts.bat

Make sure your drive maps run before the copy commands!
0
 
LVL 12

Expert Comment

by:zoofan
ID: 24300292
If you are not set on using a batch file, here is a vbscript that you can assign with a gpo to create the shortcut for you.
Will place the shortcut in the "All Users" desktop folder.

copy and paste the script into notepad modify configuration where noted and save as Filename.vbs put it where your gpo can get to it.



zf


Option Explicit
	Dim strTargetDirectory
	Dim strTargetFile
	Dim strStartIn
	Dim strDESTFolder
	Dim strNEWlink
	Dim strLinkFileName
	Dim strLinkDescp
	Dim objShell
			
			'EDIT LINK CONFIGURATION HERE AS NEEDED
			strLinkFileName = "Link_To_Boot_INI"
			strLinkDescp ="Custom Shortcut Description"
			strTargetDirectory = "c:\"
			strTargetFile = "boot.ini"
			strStartIn = "d:\"
		
	Set objShell = CreateObject("WScript.Shell")
	strDESTFolder = objShell.SpecialFolders("AllUsersDesktop")
	Set strNEWlink = objShell.CreateShortcut(strDESTFolder & "\" & strLinkFileName & ".lnk")
	strNEWlink.Description = strLinkDescp
	strNEWlink.TargetPath = strTargetDirectory & strTargetFile
	strNEWlink.WorkingDirectory = strStartIn
	strNEWlink.IconLocation = "C:\Windows\System32\SHELL32.dll, 13" 
	strNEWlink.Save
	
	WScript.Quit(0)

Open in new window

0
 
LVL 12

Expert Comment

by:zoofan
ID: 24300352
One more thing I should have mentioned,

After the shortcut is created on first gpo apply, when the gpo that calls the script updates the next time it will overwrite the shortcut properties if the link file name has not changed, if you change the link file name it will create a new link and leave the old one.

So if you never change the script only one shortcut will appear regardless of updates applied,

If you need to change the properties of the link do so in the script but leave the link file name the same and on next apply the link will be updated.

If you wish to rename the link then you will need to add to this script to delete the old link and create the new one.


hoping this makes sense,  if not let me know.


zf
0
 
LVL 12

Expert Comment

by:zoofan
ID: 24300632
btw you can call the vbscript from your existing batch file.



zf
0
 
LVL 16

Author Comment

by:rbudj
ID: 24314073
im still working on this... will report back
0
 
LVL 16

Author Closing Comment

by:rbudj
ID: 31577799
thank you.  I did it a bit differently but you were on the right track and is very close to my solution.
0
 
LVL 12

Expert Comment

by:zoofan
ID: 24437184
If you need help implementing it just ask.



zf
0
 

Expert Comment

by:8r0k3n71nX
ID: 24621202
Great work, zoofan. Thanks!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
non-domain members are not prompted for credentials 18 60
powershell script 9 63
WMI - Issue Server 2012 R2 1 18
What are the basic system requirements for SQL ALWAYS ON? 1 28
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question