# Copy program to User desktop with logon script



## BartCl (Mar 23, 2012)

Hi,

I have to copy a program to the desktop of all the users in the network. i was thinking to push this with a logon script but don't know where to start can somebody help me please.

Kind regards

Bart


----------



## loda117 (Aug 6, 2010)

Hi and Welcome to TSF 
You want to actually copy a whole program or just a shortcut of the program to the desktop? 

@echo off

start /max "C:\Windows\System32\Notepad.exe" (or another path)


----------



## BartCl (Mar 23, 2012)

Yes, it just the quick support of teamviewer, and i placed it now on a network share, so can i distribute it from there too all users with a group policy?

kind regards


----------



## Maz_- (Nov 4, 2008)

use the xcopy command to copy the file accross.

For example:

if exist "%userprofile\desktop\filename.exe" goto end 
xcopy \\servername\copyfrom %userprofile%\desktop 
:end

Put the file you want to copy in the copyfrom folder and save the above command as a .bat file. using GPO attach it to a OU and execute the script at logon.


----------



## BartCl (Mar 23, 2012)

maz i tried it like you told but it doesn't work

@echo off
if exist "%userprofile\desktop\filename.exe" goto end 
xcopy \\servername\copyfrom %userprofile%\desktop 
:end

i saved it like a batch file, and placed it in the ou group policy user @ logon
what i'm i doing wrong


----------



## BartCl (Mar 23, 2012)

here is the script i'm using

@echo off
if exist "%userprofile%\desktop\Teamviewer.exe" goto end 
xcopy \\Server1\sysvol\bart.scripts\Teamviewer.exe" "%userprofile%\desktop
:end


----------



## Maz_- (Nov 4, 2008)

You need to use this:

@echo off
if exist "%userprofile%\desktop\Teamviewer.exe" goto end 
xcopy \\Server1\sysvol\bart.scripts\ %userprofile%\desktop
:end 

Errors: You had the " after teamviewer.exe and before userprofile. If you specify the file name it doesnt work. It needs the directory and it will copy over everything in that directory so in this instance it will copy everything in bart.scripts folder.

If you like you can create a teamviewer folder in bart.scripts folder and put the .exe file there. That will work as i have tested it.


----------



## mattheworsak (Aug 22, 2011)

@MAZ

So im having the same issue. I'm trying to write a .bat file that will copy a file from one location to another location. Then im going to use "task Scheduler" to run that file every time i login to ensure i have an updated copy. My question to you is what do i use if there is spaces in the file names? Also, when it copies each time does it over write the old file and will it have the exact same name?


----------



## Maz_- (Nov 4, 2008)

If a file with the same name exists it will not do anything.

As for a space in the file name it wont matter because it is copying all files within a folder. So if you store the file that you want to copy in a folder then it should work without any problems.


----------

