Writing a little script to uninstall Winvnc. My script is supposed to remove the C:\VNC folder but I keep getting :
cannot remove item c:\vnc\winvnc.exe: Access to the path ‘winvnc.exe’ is denied.
The odd part is that when I step through the lines manually it works with no errors. Is there something different about the way scripts are run vs how they are run manually?
It’s possible that the uninstaller just isn’t getting enough time to complete before moving on to deletion. Try tossing a Start-Sleep in between those two and give it some time to finish.
I suspect Stop-Service is running fairly quickly and synchronously. I think the uninstall is what takes time, and it may be running asynchronously. So would Start-Sleep, after the uninstall and before the deletion, be something to try?