Solved

Copying a shortcut link using VBS script

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

895 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

17 Experts available now in Live!

Get 1:1 Help Now