title: Script for changing shortcut targets in a batch?
body: <p>My external hard drive was recently affected by the recycler.exe virus when I lent it to a friend. The virus affects only external drives. It changes the folders into shortcuts to those folders via an EXE file that it creates.</p>
  
  <p>I am searching for a script to change all the shortcut targets to <strong>K:\{shortcut name}</strong>. However, I don't know scripting and in the last two days that I have tried to learn scripting, I am not sure which one I should use. VBScript seems the best option, but that's just my opinion.</p>
  
  <p><strong>Problem:</strong>
  For example, earlier I had a folder called 'Anime'. Now I have a shortcut linking to that folder with the following target:</p>
  
  <p><em>%windir%\system32\cmd.exe /c "start %cd%RECYCLER\894133bf.exe &amp;&amp;%windir%\explorer.exe %cd%Anime</em></p>
  
  <p>The virus also creates a folder(and file) <strong>\RECYCLER\894133bf.exe</strong> and the shortcuts are linked through that EXE file (seen above).</p>
  
  <p>I would like a batch file to convert the target path to:
  <em>K:\Anime</em></p>
  
  <p>This way the shortcut can directly link to the file. The virus and folder were removed by Norton when I got my hard drive back. However, the shortcuts remain and they don't work unless I change the target path.</p>
  
  <p>Since I have over 37 folders on my hard drive which have been converted to the shortcuts, I was thinking that maybe a script would be helpful doing the following:</p>
  
  <ol>
  <li>Extracting the filename from the shortcut</li>
  <li>Removing the .lnk from filename </li>
  <li>Changing the target to <strong>K:\{shortcut name}</strong></li>
  <li>Go to next folder and loop until last folder</li>
  </ol>
  
  <p>I came across a script to extract a filename here:
  <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2006/05/30/how-can-i-extract-just-the-file-name-from-the-full-path-to-the-file.aspx" rel="nofollow">http://blogs.technet.com/b/heyscriptingguy/archive/2006/05/30/how-can-i-extract-just-the-file-name-from-the-full-path-to-the-file.aspx</a></p>
  
  <p>However, I do not know how to put it in a loop to do it for each folder.</p>
  
  <p>Any help will be much appreciated. Thank you very much.</p>