Solved

Copying a shortcut link using VBS script

Posted on 2011-02-13
5
523 Views
Last Modified: 2012-05-11
Hi chaps,

I'm having a bit of a struggle trying to get a script to work which copies a shortcut lnk file from a server share to a users desktop.  I've found the attached code below on here and changed it to my needs, but I get a problem in that I get a message saying that in line 6 there is an error as the file specified cannot be found.  I know it's there and have checked everything.

The only thing I can think of is that I'm trying this over a VPN connection.  Would that make a diffference?

Any help would be appreciated.
Matt
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set objProcess = objShell.Environment("Process")
strDesktop = objProcess.Item("UserProfile") & "\Desktop\"
boolOverwrite = False
objFSO.CopyFile "\\myServer\myShare$\InfoChecking\Auditing.lnk", strDesktop, boolOverwrite

Open in new window

0
Comment
Question by:2toria
[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
5 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 34882857
try add the network credentials to your server before copy using cmdkey:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22676274.html
0
 
LVL 8

Author Comment

by:2toria
ID: 34882903
I don't have admin rights to do this and doubt our network guys will change stuff just for me, unfortunately...  Is there any other way I can get this to work?  Is it to do with VPN access?
0
 
LVL 11

Expert Comment

by:yelbaglf
ID: 34883039
What about setting this up in a logon script, so that it runs with the proper permissions?
0
 
LVL 8

Author Comment

by:2toria
ID: 34883161
I don't have administrator access to carry this kind of thing out unfortunately.
0
 
LVL 13

Accepted Solution

by:
Daz_1234 earned 500 total points
ID: 34887015
Hi Matt,

Can you actually see the shortcut with your own eyes by browsing to it using Windows explorer.

Can you see it when you do:

- Click Start / Run and enter
    \\myServer\myShare$\InfoChecking
  .. into the box?

If so, then the script should work (providing, of course, that the file does already exist on your desktop).  It sounds obvious, but double check the spelling of the path.

Regards,
Daz.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
where to download correct copy of Scriptomatic 2.0 Scripting Guys 4 176
Need help Creating PowerShell Script 5 78
Code Coverage and Coding Standards 2 75
VB6 Enviroment 3 28
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

742 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