copy using windows logon script

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?
NormanDaoustAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nihlcatCommented:
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
nihlcatCommented:
Oops, sorry I copied from my batch file wrong:

copy "%SystemRoot%\shared_folder\YOURSHORTCUT.LNK" "c:\Documents and Settings\All Users\Desktop"
0
NormanDaoustAuthor Commented:
if at all possible I would like to accomplish this using vbs since all other scripts on our system are vb scripts.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

nihlcatCommented:
Oh, ok.  Someone else will have your anser then.  :)
0
Chris DentPowerShell DeveloperCommented:
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
Chris DentPowerShell DeveloperCommented:

hehe all that to achieve the one line nihlcat posted ;)
0
nihlcatCommented:
=)
0
Chris DentPowerShell DeveloperCommented:
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
NormanDaoustAuthor Commented:
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
NormanDaoustAuthor Commented:
... 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
Chris DentPowerShell DeveloperCommented:

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
Chris DentPowerShell DeveloperCommented:

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

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.