# Batch or VBScript to add a shortcut to Desktop for certain users

Hi..
I've been searching EE but I can't seem to find exactly what I need.

I have a shortcut http:\\Imp that I need to place on certain users desktop.  These users may be part of group or may not be part of a group so I am not easily able to use AD.
Is there a way with VBScript or Batch file that I can add this shortcut to specific users, where the users are in a text file?

Thanks.
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Yes, but why not create a group in AD and then just check for group membership?  There's no realistic limit to the number of groups that can be used.

Otherwise, you would use FOR:

For /f "tokens=1" %%a in (users.txt) do if "%%a"=="%username%" copy "x:\path\to\shortcut.lnk" "%userprofile%\desktop"
Author Commented:
what is x:\path\to\shortcut.lnk?
All I have been given is http:\\Imp.  Its supposed to open an IE8 window so the users can then use the web-based application.
Would the path in the file be the actual path of the application?
Commented:
You can add a script for each specific user.  Open AD, select a user, properties, Profile, logon script.  Put here the location of the script.

But like leew said, the easiest way is to make a new group for these users.
Author Commented:
Its been a rough day and I know I know the answer but I'm going to ask anyway...
IF I can get my customer to use AD (which I prefer) would you recommend using GPO to add the shortcut or something else within AD?
Network ManagerCommented:
leew can correct me if I'm wrong but I believe he is going on the assumption that you have the ICON stored somewhere on the server. (You have created the ICON and tested that it works haven't you?) The x:\path\to\shortcut.lnk telling the batch file where that ICON is so it can copy it to the desktop. Make sense?

If you can get them to use AD then it might be easier to use GPO as there is not a native "if member" in Windows like there is in Novell.

Did I miss anything

Author Commented:
To be honest, I have no idea if there is an icon or not.  All I was given by the customer is to add a shortcut that when clicked will open up IE8 and get users to the application... all I was given was http:\\IMP (IMP is the name of the application).
I don't mess with shortcuts or icons very often so its kind of new to me.  Usually the icons/shortcuts are already created in some location and I add it to a logon script, but the customer has none of that and they don't want to use a logon script.
So I have to find other ways of doing it.  I was looking for a plan B if plan A (Active Directory) doesn't work.
I would prefer to just add all these users to a group in AD and then just add the link they need to a GPO for them.
Network ManagerCommented:
Here is a script to add a shortcut to www.google.com. It should be easy enough to modify.
@echo off


Author Commented:
Can I just add that to the GPO (i.e. have the GPO call that script) for the selected users?
Actually you said "I have a shortcut" - so in my script is the path to the shortcut - .lnk files are shortcuts.  .url files are favorites in IE (though I suppose some would call them INTERNET shortcuts.  In either case, you would copy whatever the file is that contains your shortcut - that's what x:\path\to\shortcut.lnk is supposed to represent.
Author Commented:
With what you all have posted, it appears the best or easiest way is to put a script in some sort of batch file and call that batch file via GPO, is that correct?
Do you recommend that over using Active Desktop within AD/GPO?
That's what I'd be doing - either in the login script or via a group policy, checking group membership and if a member, copying the shortcut.
Network ManagerCommented:
Actually, if there is no reason that everyone can't have access to the http:\\lmp "site", or if there is security on that "site" then the easiest way may be to use GPO and add the link to everyone's favorites. That eliminates unnecessary "clutter" on the desktop and eliminates the need to copy anything.
Author Commented:
The customer believe if we use GPO then if the user deletes the shortcut or favorite then it will come back when the user next logs in.
Is there a way to use GPO and then make sure when its deleted it won't come back?
Network ManagerCommented:
That could be accomplished with some more work by using the RunOnce but I would need to work on that.

Another way is to have the user open IE to the site and then go to File/Send/Shortcut to Desktop and that way only the ones that need/want it would get the shortcut on their desktop. Then if they can delete it if they don't need/want it anymore.
The reason you put something this in a login script is to ensure it's always there.  If you want the user to have the option of deleting it, then I would just run a script as domain admin and place the shortcut on the designated machines.

For example, make a list of all the machines that should get this shortcut and then run
For /f "tokens=1" %%a in (users.txt) do if "%%a"=="%username%" copy "x:\path\to\shortcut.lnk" "\\%%a\c$\documents and settings\all users\desktop" This isn't foolproof - if you have vista or 7 clients you'll have to change the copy to path... but the idea is once it's on the machine never to do it again, then you don't want this done by a script that repeats every logon. Author Commented: Just finished talking with the customer. They don't want to use GPO. They want it so the user has the ability to delete it without it coming back. We use roaming profiles, so its not based on machine, its based on user. I already asked why they don't just have the user bookmark the web page, and they said that isn't an option. So, I am pretty much limited to creating a script that can run that will simply use xcopy to put a shortcut for a web page on a desktop. They do not use a path for shortcuts (as stated above, i.e. shortcut.lnk) so I either have to create that path myself or simply put the URL in the xcopy. I've never used xcopy so I'm not sure how to implement that with vbscript. I do have the list of users and their profile path. Network ManagerCommented: Okay, Do you agree with this then leew? 1. Do you have access to http:\\lmp (I am guessing that is a lower case L) 2. If so, then go to the site and then create a shortcut on your desktop File/Send/Shortcut to Desktop 3. Using the script leew gave you to start with copy the shortcut from your desktop to the %username%\desktop directory where the roaming profiles are stored. Author Commented: I have the following in my VBScript but its been a long time since I've used command line within VBScript. How would I read the users from the file and execute the command? rcmd For /f ""tokens=1"" %%a in (c:\users.txt) do if ""%%a""==""%username%"" xcopy ""\\BOS-S-2-FS1\%username%\System\XP\Desktop" Network ManagerCommented: The (c:\users.txt) is where you put the location\name of the file. Technology and Business Process AdvisorCommented: In general yes, but I always recommend testing on a machine or two first. Though let me revise the command - the one posted most recently puts the shortcut on the desktop of all users for the machine in question. but if we don't want ALL users of a given machine to see it, then we should copy it to the user's roaming profile WHILE THEY ARE LOGGED OUT (this is why I hate roaming profiles - if they used folder redirection, this wouldn't be an issue and would be faster on the network) Do this at night or on a weekend or early before they arrive; For /f "tokens=1" %%a in (users.txt) do if "%%a"=="%username%" copy "x:\path\to\shortcut.lnk" "\\RoamingProfilesServer\ProfileShare\UserName(IfApplicable)\Desktop" NOTE: I'm using plain old copy - NOT xcopy. XCOPY can work, but why bother? If you need more help with this, I'd recommend posting the EXACT name of the file the shortcut is - and it's path, as well as an example path to one of the users profiles. Experts Exchange Solution brought to you by Your issues matter to us. Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle. Author Commented: this is what is in my users.txt: \\servera\username$
and on down the list.
The place I need to copy it to is \servera\username\system\dekstop (where servera changes based on their location).
The shortcut is located on my desktop c:\docs and settings\....\http:\\IMP

Network ManagerCommented:
leew:

What do you think of the following? I think there is something wrong in the way I have it but I can't put my finger on it.

For /f "tokens=2,3 delims=^\ (users.txt) do if "%%b"=="%username%" copy "%userprofile%\desktop\<name of shortcut> "%%a\%%b\system\Desktop"