
在桌面應用程式重新安裝或更新期間,我需要確保應用程式的資源未開啟或目前正在使用。
使用批次文件,我嘗試確定目錄是否透過 Windows 資源管理器或命令視窗開啟。這可能嗎? 如果可能的話,我將如何實現這一目標?
先感謝您
答案1
在 Powershell 中使用一行程式碼,您可以編寫類似的程式碼來取得所有開啟的資料夾:
電源外殼 :
@((New-Object -com shell.application).Windows()).Document.Folder | ForEach { $_.Self.Path }
在批次檔中使用 PowerShell 程式碼取得開啟的資料夾:
@ECHO off
@Title Get Opened Folders with PowerShell code in a batch file
Powershell -C "@((New-Object -com shell.application).Windows()).Document.Folder | ForEach { $_.Self.Path }"
pause