Solved

script to create desktop shortcut

Posted on 2007-11-19
6
856 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now