Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
batchfileman
- Posts: 16
- Joined: 07 Jun 2010 10:27
#1
Post
by batchfileman » 24 Jun 2010 08:38
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
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 24 Jun 2010 13:09
Have you access to work into a different users profile?
What about "%ALLUSERSPROFILE%\Desktop" to show it on each users desktop?
Regards
aGerman
-
batchfileman
- Posts: 16
- Joined: 07 Jun 2010 10:27
#3
Post
by batchfileman » 24 Jun 2010 13:15
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.
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#4
Post
by aGerman » 24 Jun 2010 15:59
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