Example:
$ scoop uninstall openssh
uninstalling openssh (5.4p1-1)
removing shim for scp
removing shim for sftp
removing shim for slogin
removing shim for ssh-add
removing shim for ssh-agent
removing shim for ssh-keygen
removing shim for ssh-keyscan
removing shim for ssh
couldn't remove ~/appdata/local/scoop\apps\openssh\5.4p1-1: it may be in use
I'm thinking that users should be able to uninstall apps regardless of whether it is running or not - which means that we need some way of stopping services before uninstalling, so that the user doesn't need to figure it out themselves.
Agreed! But then there should be a way to add services in the first place not ?
First thing to do when uninstalling should be check for directory is in use. With information about folder is in use and two options: (it would require --force parameter for uninstallation)
I could think only using Get-Process. Something like:
$procs = Get-Process -FileVersionInfo -ErrorAction SilentlyContinue | ? { $_.FileName -like '$dir`*'}
# or
# Create some hashtable from Get-Process with ID as key and Path as Value Get-Process | Select-Object Path, ID
if ($procs.Count -gt 0 -and !$forceParam) {
abort 'Folder is in use. if you want to let scoop kill all process use unisntall -f'
} else {
#Kill all process, which are running and continue uninstallation
$procs | ForEach-Object { Stop-Process $_ }
}
@r15ch13 Do you have better solution?
Result of get-process for running Steam

PS C:\Windows\system32> (Get-Process -FileVersionInfo -ErrorAction SilentlyContinue | ? { $_.FileName -like 'D:\scoop\ap
ps\Steam*'})
ProductVersion FileVersion FileName
-------------- ----------- --------
2018.2.13.864... 2018.2.13.864... D:\SCOOP\apps\Steam\current\steamapps\common\God Awe-full Clicker\GAC.exe
03.00.00.01 04.83.53.91 D:\SCOOP\apps\Steam\current\GameOverlayUI.exe
01.00.00.01 04.83.53.91 D:\SCOOP\apps\Steam\current\Steam.exe
01.00.00.01 04.83.53.91 D:\SCOOP\apps\Steam\nightly-20181111\bin\cef\cef.win7\steamwebhelper.exe
01.00.00.01 04.83.53.91 D:\SCOOP\apps\Steam\nightly-20181111\bin\cef\cef.win7\steamwebhelper.exe
01.00.00.01 04.83.53.91 D:\SCOOP\apps\Steam\nightly-20181111\bin\cef\cef.win7\steamwebhelper.exe
01.00.00.01 04.83.53.91 D:\SCOOP\apps\Steam\nightly-20181111\bin\cef\cef.win7\steamwebhelper.exe
01.00.00.01 04.83.53.91 D:\SCOOP\apps\Steam\nightly-20181111\bin\cef\cef.win7\steamwebhelper.exe
01.00.00.01 04.83.53.91 D:\SCOOP\apps\Steam\nightly-20181111\bin\cef\cef.win7\steamwebhelper.exe
D:\SCOOP\apps\Steam\current\steamapps\common\God Awe-full Clicker\UnityCrashHandle...
PS C:\Windows\system32> (Get-Process -FileVersionInfo -ErrorAction SilentlyContinue | ? { $_.FileName -like 'D:\scoop\ap
ps\Steam*'}).Count
10
Good idea 馃憤
It's a bit faster when the -FileVersionInfo isn't used. We don't need the file version for this. The Path property is enough.
Warning the user and do nothing would be the best way. This should also be implemented in the update process to skip running programs.
(Get-Process | ? { $_.Path -like 'D:\scoop\apps\*'} )
(Get-Process | ? { $_.Path -like 'D:\scoop\apps\<app>\*'} )
位 (Get-Process | ? { $_.Path -like 'D:\scoop\apps\*'} )
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
2238 176 322672 451496 746,63 3832 8 firefox
1654 198 868320 820768 701,23 17776 8 firefox
1506 150 454816 436532 107,84 19904 8 firefox
823 33 153628 170696 387,61 20420 8 firefox
809 138 390228 475888 79,34 27380 8 firefox
1524 166 481256 425892 300,42 30668 8 firefox
1544 165 553188 494080 229,72 30920 8 firefox
216 15 4828 83404 0,16 32460 8 firefox
448 25 53392 58904 1,31 34272 8 QuickLook
126 9 1320 6180 0,03 18816 8 QuickLook.WoW64HookHelper
355 29 44316 68388 0,92 7316 8 Wavebox
328 32 56140 82212 28,56 13692 8 Wavebox
551 49 87400 117192 2,64 17148 8 Wavebox
361 53 154552 172872 28,86 20368 8 Wavebox
1646 83 128120 166200 74,45 20576 8 Wavebox
738 43 369040 146876 21,42 20764 8 Wavebox
305 24 26568 35984 0,11 22416 8 Wavebox
370 75 252996 286688 52,16 24092 8 Wavebox
357 43 88072 117712 32,67 34092 8 Wavebox
211 14 6776 12616 0,03 34792 8 Wavebox
位 (Get-Process | ? { $_.Path -like 'D:\scoop\apps\wavebox\*'} )
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
355 29 44316 68400 0,92 7316 8 Wavebox
325 32 56116 82576 28,70 13692 8 Wavebox
551 49 87400 117428 2,64 17148 8 Wavebox
361 53 154552 172944 28,86 20368 8 Wavebox
1661 85 128088 165180 74,70 20576 8 Wavebox
738 43 369040 146876 21,42 20764 8 Wavebox
302 24 26144 36320 0,11 22416 8 Wavebox
379 76 246384 281988 52,16 24092 8 Wavebox
359 43 87176 117444 32,81 34092 8 Wavebox
211 14 6776 12616 0,03 34792 8 Wavebox
Fixed as soon as #3608 arrive in master
Proper implementation will follow in #2952
Implemented in https://github.com/lukesampson/scoop/pull/3608
Most helpful comment
Good idea 馃憤
It's a bit faster when the
-FileVersionInfoisn't used. We don't need the file version for this. ThePathproperty is enough.Warning the user and do nothing would be the best way. This should also be implemented in the update process to skip running programs.