?
Solved

script to create desktop shortcut

Posted on 2007-11-19
6
Medium Priority
?
870 Views
Last Modified: 2012-08-13
I have put this script under GPO /logon when I logon  the script creates a shortcut under c:\document and settings\username instead of the desktop.


Set oWS = WScript.CreateObject("WScript.Shell")
strDesktop = ows.SpecialFolders("Desktop")  
   sLinkFile = "ADminProject.LNK"
   
   Set oLink = oWS.CreateShortcut(strdesktop & sLinkFile)
   
   
   oLink.TargetPath = "C:\Documents and Settings\%username%\NetHood\Network Administrator files on sharepointserver"
      oLink.Save
0
Comment
Question by:jskfan
[X]
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
  • 3
  • 2
6 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 20315977
Hi, use this:

'===============
Set oWS = WScript.CreateObject("WScript.Shell")
Set oWN = WScript.CreateObject("WScript.Network")
strDesktop = ows.SpecialFolders("Desktop")
If Right(strDesktop, 1) <> "\" Then strDesktop = strDesktop & "\"
sLinkFile = "ADminProject.LNK"

Set oLink = oWS.CreateShortcut(strdesktop & sLinkFile)
oLink.TargetPath = "C:\Documents and Settings\" & oWN.UserName & "\NetHood\Network Administrator files on sharepointserver"
oLink.Save
'===============

One problem was that strDesktop did not have a trailing slash, so you were creating a file under the username folder called DesktopADminProject.LNK

A second problem was that the %username% variable can only be used in DOS, to use the same in VBScript you need to create a WScript.Network object, and use oWN.UserName

Regards,

Rob.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20317087
Hi Rob,

When is your marriage

Advance wishes for your marriage and have a nice time. :-)

cheers
Chandru
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20317099
This Saturday.....only three days away!  Then I will be away until the new year!  I need a holiday, so we're going to enjoy it!

Thanks Chandru.

See you in the new year!

Regards,

Rob.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Expert Comment

by:chandru_sol
ID: 20317108
Happy Christmas and also a prosperous New year 2008............ and Happy married life

Yes you really need a holiday.........

Wow! this saturday. Good. Congrats..........

See you

regards
Chandru
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20317175
Thanks!  Keep up the good work here on EE, you've answered a lot of questions lately. Excellent job!

I find that answering the different queries of others has been the fastest way for me to learn new things.

Happy Christmas in advance to you as well, and jskfan too!

Regards,

Rob.
0
 

Author Closing Comment

by:jskfan
ID: 31410027
Excellent !!!!!!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

771 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