Solved

Copying a shortcut link using VBS script

Posted on 2011-02-13
5
521 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
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…

839 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