Solved

Default User and All user path

Posted on 2013-06-19
15
485 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 83

Expert Comment

by:oBdA
ID: 39260191
"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
ID: 39260296
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 83

Expert Comment

by:oBdA
ID: 39260363
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
ID: 39260400
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 83

Expert Comment

by:oBdA
ID: 39260409
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
ID: 39260416
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 83

Expert Comment

by:oBdA
ID: 39260434
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 2

Author Comment

by:fadyaz
ID: 39260441
this is the error

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

Expert Comment

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

Author Comment

by:fadyaz
ID: 39260486
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 83

Expert Comment

by:oBdA
ID: 39260503
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
ID: 39260549
Thanks it is work fine with windows 7 and XP

thanks alot
0
 
LVL 2

Author Comment

by:fadyaz
ID: 39260557
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 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 39260600
@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
ID: 39260656
Excellent answers and Following UP.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unable to disassociate and associate elastic IP address EC2-VPC 6 45
Linux Scripting 3 96
Active DirectoryScript to change the Pager Field 1 47
AWS CLI issues with Tags 3 62
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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 demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

930 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

10 Experts available now in Live!

Get 1:1 Help Now