OK. I want to stop the running process, and then continue with the script only after the process terminates.
for example: stop the media player, and then delete the media player database (if you have wmp12, you can understand the reason!) But the rest of the script starts to run before the application has time to shut down.
#stop wmp stop-process -processname wmplayer #delete dir "C:\Users\blergh\AppData\Local\Microsoft\Media Player" -filter *wmdb | foreach { del $_.fullname}
And I get:
Remove-Item : Cannot remove item C:\Users\blergh\AppData\Local\Microsoft\Media Player\CurrentDatabase_372.wmdb: The proces s cannot access the file 'C:\Users\blergh\AppData\Local\Microsoft\Media Player\CurrentDatabase_372.wmdb' because it is bei ng used by another process.
Can I make it work synchronously?
Thanks, P
source share