Page 1 of 1

Copy to individual profiles

Posted: 24 Jun 2010 08:38
by batchfileman
So I am wanting to copy a shortcut to an individual user's profile. I currently have a batch file that will allow me to find all of the usernames on my local machine. What I would like to do is to then use these usernames that this batch comes up with to apply a shortcut to the individual user's desktop using the usernames drawn up from this original batch.

Any suggestions on how to achieve this?

The original batch that get's the usernames.
@echo off &setlocal
pushd "C:\Documents and Settings"
for /f "delims=: tokens=1*" %%a in ('dir /ad /b^|findstr /n .') do set "userVar%%a=%%b"
popd

:: display all
set userVar


pause



I suspect that I should be able to send the variables I get from this first batch to another batch file that then installs the shortcut based on the usernames it receives. Any help would be greatly appreciated

Re: Copy to individual profiles

Posted: 24 Jun 2010 13:09
by aGerman
Have you access to work into a different users profile?

What about "%ALLUSERSPROFILE%\Desktop" to show it on each users desktop?

Regards
aGerman

Re: Copy to individual profiles

Posted: 24 Jun 2010 13:15
by batchfileman
Unfortunately I cannot take the risk of putting it just in all users. It actually has to be in each and every profile on the machine individually. (I am actually replacing an old shortcut which has been place in each profile by a now obsolete program which was designed to do this exact thing.)
As much as I'd like to say all users and be done with it I can't, it has to be each and every individual user's profile.

Re: Copy to individual profiles

Posted: 24 Jun 2010 15:59
by aGerman

Code: Select all

@echo off &setlocal
pushd "%userprofile%\.."
for /f "delims=" %%a in ('dir /ad /b') do (
  set "userDesktop=%%~dpnxa\Desktop"
  call :proc
)
popd
pause
goto :eof

:: ~~~~~~~~~~~~~~~~~~~
:proc
echo %userDesktop%
goto :eof



Do your copy stuff in subroutine :proc.

Regards
aGerman

Re: Copy to individual profiles

Posted: 28 Jun 2010 08:31
by batchfileman
You're sharp. Thank you so very much.