Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,006 of 68,980    |
|    Zaidy036 to Tim Rude    |
|    Re: Expand a variable within a variable    |
|    14 Aug 17 11:16:54    |
      From: Zaidy036@isp.spam              On 8/13/2017 10:58 PM, Tim Rude wrote:       > I'm trying to obtain the current user's desktop path to pass as a       > command-line parameter to an old DOS app that will be running under       > Win7/8/10.       >       > I can get the path from the registry using:       >       > for /f "usebackq tokens=1,2,*" %%B IN (`reg query       > "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User       > Shell Folders" /v Desktop`) do set DT=%%D       >       > On a default install of Win7, that sets the %DT% environment variable to       > '%USERPROFILE%\Desktop' since that's what's stored in the registry.       >       > However, I need the '%USERPROFILE%' part expanded to the actual path, so       > that I end up with %DT% being (for example) 'C:\Users\Tim\Desktop'.       >       > How can I get my batch file to expand the %USERPROFILE% variable that's       > within the %DT% environment variable?              SET DT=%DT:Desktop=%              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca