Solved

Copying a shortcut link using VBS script

Posted on 2011-02-13
5
516 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
Comment Utility
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
Comment Utility
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
Comment Utility
What about setting this up in a logon script, so that it runs with the proper permissions?
0
 
LVL 8

Author Comment

by:2toria
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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.
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.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 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

18 Experts available now in Live!

Get 1:1 Help Now