Solved

Copying a shortcut link using VBS script

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

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…
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.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

717 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