Solved

script to create desktop shortcut

Posted on 2007-11-19
6
866 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
Independent Software Vendors: 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

Independent Software Vendors: 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

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

739 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