Script that removes itself
<p>How to write a script that removes itself from hard drive. Let's assume following example what I want to achieve:</p>

<pre><code>&gt; dir
script.ps1
&gt; powershell script.ps1
&gt; dir   # &lt;-- file do not exists
&gt; 
</code></pre>

<p>I am not familiar with power-shell, but I suppose it should look like below:</p>

<ol>
<li>script creates a process that is waiting</li>
<li>script ends it's life</li>
<li>process removes the script.ps1 file from HD</li>
<li>process kills itself</li>
</ol>

<p>The problem is that I don't know how to dynamically create a process that will wait for script to finish its job and then remove the file. Appreciate your help.</p>