Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

copy using windows logon script

Posted on 2004-10-26
12
Medium Priority
?
1,179 Views
Last Modified: 2010-04-19
I would like to copy a shortcut to the desktop of each domain user. I have put the shortcut in a shared directory on the server and set permissions. How do copy it to the All Users Desptop of each computer upon user login?
0
Comment
Question by:NormanDaoust
[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
  • 4
  • 3
12 Comments
 
LVL 6

Expert Comment

by:nihlcat
ID: 12412979
You can create a batch file containing:

copy "%SystemRoot%\shared_folder\calc.exe" "c:\Documents and Settings\All Users\Desktop"

and name it something like "sortcut.bat"

Then you can add it to their Profile tab under their account, or push it out via group policy
0
 
LVL 6

Expert Comment

by:nihlcat
ID: 12412998
Oops, sorry I copied from my batch file wrong:

copy "%SystemRoot%\shared_folder\YOURSHORTCUT.LNK" "c:\Documents and Settings\All Users\Desktop"
0
 

Author Comment

by:NormanDaoust
ID: 12413404
if at all possible I would like to accomplish this using vbs since all other scripts on our system are vb scripts.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:nihlcat
ID: 12413429
Oh, ok.  Someone else will have your anser then.  :)
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 12413598
To copy a file with VBScript...

set objFileSystem = CreateObject ("Scripting.FileSystemObject")

set objFile = objFileSystem.GetFile("<source file>")
objFile.Copy("<target file>")

Now to make things slightly more complicated you'll have to teach VBScript how to read an Environmental Variable (if you wanted to use the %UserProfile% path).

If you assume the source file name and destination are the same you get this little script:

' Script to copy a file

Option Explicit

' Variable Declaration

Dim objFileSystem, objShell
Dim objEnVar, objFile
Dim strUserVar, strTargetPath

' Constant Declaration

Const FILE = "<File Name to Copy>"

' Initialize Objects

Set objFileSystem = CreateObject ("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")

' Figure out what UserProfile is

Set objEnVar = objShell.Environment("PROCESS")
strUserVar = objEnVar.Item("UserProfile")

' Building the Target path - this one dumps it onto the Desktop for the current user

strTargetPath = strUserVar & "\Desktop\" & FILE

' Copy the file

set objFile = objFileSystem.GetFile(FILE)
objFile.Copy(strTargetPath)
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 12413614

hehe all that to achieve the one line nihlcat posted ;)
0
 
LVL 6

Expert Comment

by:nihlcat
ID: 12413627
=)
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 12413684
Although I did miss the All Users bit... that simplifies things slightly - well if you can at least assume everyone uses the C: Drive:

' Script to copy a file

Option Explicit

' Variable Declaration

Dim objFileSystem
Dim objFile

' Constant Declaration - These must include the Filename itself

Const SOURCE = "<Source Path and File Name>"
Const DESTINATION = "C:\Documents and Setttings\All Users\Desktop\<filename>"

' Initialize Objects

Set objFileSystem = CreateObject ("Scripting.FileSystemObject")

' Copy the file

set objFile = objFileSystem.GetFile(SOURCE)
objFile.Copy(DESTINATION)

A little easier...
0
 

Author Comment

by:NormanDaoust
ID: 12414181
good point abou the C: drive, it may not always be the case. So I am trying to run the first chunk of code and I'm getting a path not found error from the line: objFile.Copy(strTargetPath)
0
 

Author Comment

by:NormanDaoust
ID: 12414227
... In fact, here is the modified code I'm trying to run. Is this right Chris-Dent?

Option Explicit

' Variable Declaration

Dim objFileSystem, objShell
Dim objEnVar, objFile
Dim strUserVar, strTargetPath

' Constant Declaration

Const FILE = "\\crispserv\portal\CRISP Portal.lnk"

' Initialize Objects

Set objFileSystem = CreateObject ("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")

' Figure out what UserProfile is

Set objEnVar = objShell.Environment("PROCESS")
strUserVar = objEnVar.Item("UserProfile")

' Building the Target path - this one dumps it onto the Desktop for the current user

strTargetPath = strUserVar & "\Desktop\" & FILE

' Copy the file

set objFile = objFileSystem.GetFile(FILE)
objFile.Copy(strTargetPath)
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 12417028

Almost... sorry.. that version was crappy for handling different locations... try this one:

Option Explicit

' Variable Declaration

Dim objFileSystem, objShell
Dim objEnVar, objFile
Dim strUserVar, strSourcePath, strTargetPath

' Constant Declaration

Const SOURCEPATH = "\\crispserv\portal\"
Const SOURCEFILENAME = "CRISP Portal.lnk"
Const DESTFILENAME = "CRISP Portal.lnk"

' Initialize Objects

Set objFileSystem = CreateObject ("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")

' Figure out what UserProfile is

Set objEnVar = objShell.Environment("PROCESS")
strUserVar = objEnVar.Item("UserProfile")

' Building the Target path - this one dumps it onto the Desktop for the current user

strSourcePath = SOURCEPATH & SOURCEFILENAME
strTargetPath = strUserVar & "\Desktop\" & DESTFILENAME

' Copy the file

set objFile = objFileSystem.GetFile(strSourcePath)
objFile.Copy(strTargetPath)
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 1600 total points
ID: 12417032

Anyway, for this version it'll end up with:

Copy File from "\\crispserv\portal\CRISP Portal.lnk"
To "%UserProfile%\Desktop\CRISP Portal.lnk"
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

618 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