title: Autohotkey script - taskkill.exe error on Windows shutdown
body: <p>I am using lot of portable application locally on my laptop and if i leave some of them opened when i shutdown Windows it doesn't close them properly and some applications don't save their settings. I am trying to use taskkill option in a autohotkey script which will be executed on windows shutdown and will close properly opened portable application. </p>
  
  <p>I am using this script:</p>
  
  <pre><code>#SingleInstance, force 
  #Persistent 
  DllCall("kernel32.dll\SetProcessShutdownParameters", UInt, 0x4FF, UInt, 0)
  OnExit , closepgs 
  return 
  closepgs: 
  If (A_ExitReason="Shutdown" or A_ExitReason="Logoff") 
  
  {
  Run, taskkill.exe /F /IM uTorrent.exe
  }
  
  ExitApp`
  </code></pre>
  
  <p>But when i shutdown Windows i receive this taskkill.exe error:</p>
  
  <p>"Application failed to initialize properly (0xc0000142). Click on OK to terminate the application"</p>
  
  <p>If i use the taskkill code outside the script like this it works fine:</p>
  
  <pre><code>^!Home:: 
  Run, taskkill.exe /F /IM uTorrent.exe
  </code></pre>
  
  <p>But if i use it inside the script i receive taskkill.exe error.</p>
  
  <p>Any idea why this error happening?</p>
  
  <p>I have Windows XP Pro SP3. </p>