Solved

Default User and All user path

Posted on 2013-06-19
15
502 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
[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
  • 8
  • 7
15 Comments
 
LVL 84

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 84

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
How our DevOps Teams Maximize Uptime

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

 
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 84

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 84

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
 
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 84

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 84

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 84

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sqlldr issue 1 26
Use GPO script to report finding a certain file 16 16
excel VBA - clear duplicates not working 11 42
IDENTIFY, THEN ADD TOGETHER AND DELETE ONE, EXCEL 3 34
When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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