Solved

Default User and All user path

Posted on 2013-06-19
15
480 Views
Last Modified: 2013-06-19
Hello,

I need to copy a file on all our PCs. But i need this file to be available on the desktop when the users log in to their desktop.

On windows XP i copied the file to this location :
\Documents and Settings\All Users\Desktop\

On windows 7 i copied the file on this location
\Users\Default\Desktop\

How i can make the file to copy automatically on this PCs without changing the path for windows xp and windows 7 i want the file to be generic one.

can any body help me please
0
Comment
Question by:fadyaz
  • 8
  • 7
15 Comments
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
"C:\Users\Default" is not the correct location; the common desktop is in C:\Users\Public. Anyway, try this batch script:
@echo off
setlocal
for /f "tokens=3*" %%a in ('reg.exe query "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Common Desktop" ^| find.exe /i "Common Desktop"') do set CommonDesktop=%%b
echo Common desktop folder: %CommonDesktop%
copy "\\SomeServer\SomeShare\SomeFile.ext" "%CommonDesktop%"

Open in new window

0
 
LVL 2

Author Comment

by:fadyaz
Comment Utility
Hi  oBdA

Thanks for your reply. i have a list of the PCs name and this pcs for windows 7 and XP

how i copy the file to those PCs by using user script.

I'm using the following script for copying

@echo off
copy "\\servername\file.pdf" "\\PC-Name\c$\Documents and Settings\All Users\Desktop"

@echo off

Open in new window

0
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
Try this; it's in test mode and will only display the copy commands it would normally run. Remove the uppercase ECHO in line 6 to run it for real:
@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('type "C:\Temp\PCList.txt"') do (
	echo Processing %%a ...
	for /f "tokens=3*" %%f in ('reg.exe query "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Common Desktop" ^| find.exe /i "Common Desktop"') do set CommonDesktop=%%g
	ECHO copy "\\SomeServer\SomeShare\SomeFile.ext" "\\%%a\!CommonDesktop::=$!"
)

Open in new window

0
 
LVL 2

Author Comment

by:fadyaz
Comment Utility
thanks for the script i tested it but it work fine on windows 7 but on windows xp it didnt work

i need to let it work on windows xp at same time within one script

thanks
0
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
Please post the output of the following command on an XP client (you can do that remote as well by adding "\\SomeXPMachine\ in front of "HKLM"):
reg.exe query "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"

Open in new window

0
 
LVL 2

Author Comment

by:fadyaz
Comment Utility
This is the output :


HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Fold
ers
    Common AppData    REG_SZ    C:\Documents and Settings\All Users\Application
Data
    Common Programs    REG_SZ    C:\Documents and Settings\All Users\Start Menu\
Programs
    Common Documents    REG_SZ    C:\Documents and Settings\All Users\Documents
    Common Desktop    REG_SZ    C:\Documents and Settings\All Users\Desktop
    Common Start Menu    REG_SZ    C:\Documents and Settings\All Users\Start Men
u
    CommonPictures    REG_SZ    C:\Documents and Settings\All Users\Documents\My
 Pictures
    CommonMusic    REG_SZ    C:\Documents and Settings\All Users\Documents\My Mu
sic
    CommonVideo    REG_SZ    C:\Documents and Settings\All Users\Documents\My Vi
deos
    Common Favorites    REG_SZ    C:\Documents and Settings\All Users\Favorites
    Common Startup    REG_SZ    C:\Documents and Settings\All Users\Start Menu\P
rograms\Startup
    Common Templates    REG_SZ    C:\Documents and Settings\All Users\Templates
    Common Administrative Tools    REG_SZ    C:\Documents and Settings\All Users
\Start Menu\Programs\Administrative Tools
0
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
Looks normal; what's the output when you put the ECHO back into the script and change the list file to one that only contains one of the failing machines?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 2

Author Comment

by:fadyaz
Comment Utility
this is the error

The system cannot find the path specified.
        0 file(s) copied.
0
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
I need the output with the ECHO in front of the "copy" in line 6 back in.
0
 
LVL 2

Author Comment

by:fadyaz
Comment Utility
This is the output

Processing PC-namee ...
copy "c:\files\Phone User Guide.pdf" "\\PC-namee\C$\Users\Public\Desktop"
Processing PC-namee...
copy "c:\files\Phone User Guide.pdf" "\\PC-namee\C$\Users\Public\Desktop"
Processing PC-namee ...
copy "c:\files\Phone User Guide.pdf" "\\PC-namee\C$\Users\Public\Desktop"
Processing PC-namee ...
copy "c:\files\Phone User Guide.pdf" "\\PC-namee\C$\Users\Public\Desktop"

all pcs is windows xp but the path is showing for windows 7
0
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
Found it, sorry; try this:
@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('type "C:\Temp\PCList.txt"') do (
	echo Processing %%a ...
	for /f "tokens=3*" %%f in ('reg.exe query "\\%%a\HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Common Desktop" ^| find.exe /i "Common Desktop"') do set CommonDesktop=%%g
	ECHO copy "c:\files\Phone User Guide.pdf" "\\%%a\!CommonDesktop::=$!"
)

Open in new window

0
 
LVL 2

Author Comment

by:fadyaz
Comment Utility
Thanks it is work fine with windows 7 and XP

thanks alot
0
 
LVL 2

Author Comment

by:fadyaz
Comment Utility
can i add let the script to create a log file for the total of pcs that done the operation and the name of pcs didn't successfully copied ?
0
 
LVL 82

Accepted Solution

by:
oBdA earned 500 total points
Comment Utility
@echo off
setlocal enabledelayedexpansion
set LogFileSuccess=Success.log
set LogFileError=Error.log
if exist "%LogFileSuccess%" del "%LogFileSuccess%" & if exist "%LogFileError%" del "%LogFileError%"
for /f "delims=" %%a in ('type "C:\Temp\test.txt"') do (
	echo Processing %%a ...
	for /f "tokens=3*" %%f in ('reg.exe query "\\%%a\HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Common Desktop" ^| find.exe /i "Common Desktop"') do set CommonDesktop=%%g
	copy "c:\files\Phone User Guide.pdf" "\\%%a\!CommonDesktop::=$!"
	if errorlevel 1 (>>"%LogFileError%" echo %%a) else (>>"%LogFileSuccess%" echo %%a)
)

Open in new window

0
 
LVL 2

Author Closing Comment

by:fadyaz
Comment Utility
Excellent answers and Following UP.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

7 Experts available now in Live!

Get 1:1 Help Now