@@ -193,11 +193,46 @@ get_volume_paths <- function() {
193193 names(volumes_checked ) <- volumes_checked
194194 volumes_checked
195195 } else if (tolower(sysinfo [" sysname" ]) == " windows" ) {
196- volumes_string <- system(" wmic logicaldisk get caption" , intern = TRUE )
197- volumes <- unlist(stringr :: str_extract_all(volumes_string , " [A-Z]\\ :" ))
198- volumes_checked <- volumes [fs :: file_access(volumes )]
199- names(volumes_checked ) <- volumes_checked
200- volumes_checked
196+ # For Windows 11, first try PowerShell
197+ tryCatch(
198+ {
199+ volumes_string <- system(
200+ " powershell -Command \" Get-PSDrive -PSProvider FileSystem | Select-Object -ExpandProperty Name\" " ,
201+ intern = TRUE
202+ )
203+ volumes <- paste0(volumes_string [nzchar(volumes_string )], " :" )
204+ volumes_checked <- volumes [fs :: file_access(volumes )]
205+ names(volumes_checked ) <- volumes_checked
206+ volumes_checked
207+ },
208+ error = function (e ) {
209+ # Fallback: try wmic
210+ tryCatch(
211+ {
212+ volumes_string <- system(
213+ " wmic logicaldisk get caption" ,
214+ intern = TRUE
215+ )
216+ volumes <- unlist(stringr :: str_extract_all(
217+ volumes_string ,
218+ " [A-Z]\\ :"
219+ ))
220+ volumes_checked <- volumes [fs :: file_access(volumes )]
221+ names(volumes_checked ) <- volumes_checked
222+ volumes_checked
223+ },
224+ error = function (e2 ) {
225+ # Last resort: check common drive letters
226+ potential_volumes <- paste0(LETTERS [3 : 26 ], " :" ) # C: through Z:
227+ volumes_checked <- potential_volumes [fs :: file_access(
228+ potential_volumes
229+ )]
230+ names(volumes_checked ) <- volumes_checked
231+ volumes_checked
232+ }
233+ )
234+ }
235+ )
201236 } else {
202237 c(Volumes = fs :: path_home())
203238 }
0 commit comments