Solved

script to create desktop shortcut

Posted on 2007-11-19
6
865 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 500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 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