Solved

script to create desktop shortcut

Posted on 2007-11-19
6
861 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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