Need help with batch file

ramasterson

Distinguished
Apr 28, 2011
1
0
18,510
My objective is to copy a shortcut (.lnk) from a network share to the users windows startup folder. The issue is we support variuos flavors of windows (XP, Vista, 7) so the users statup folder is a moving target. I'm by no means a seasoned programer, but I've hobbled (with major help from the internet) together a batch file that almost works. My problem is I can't get the "reg query" to return the full path to the startup folder. It is truncating the path.

Can anyone take a look at what I have and make a suggestion?

Thanks for any help

for /f "tokens=3" %%a in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Startup ^| find /i "REG_SZ"') do set startup=%%a
copy "T:\Applications\Shortcuts\Chklogin.lnk" %startup%
 

Rusting In Peace

Distinguished
Jul 2, 2009
312
0
19,060
Had a quick look at this. Your key value has a space in it so simply using the third token will not work.

I don't use batch files often enough to be able to provide the solution for you though. I thought simply modifying the token to 3-4 or 3* would have been enough but not from what I little testing I've done.