從另一個使用者讀取本地“HKEY_CURRENT_USER”,windows批次/powershell

從另一個使用者讀取本地“HKEY_CURRENT_USER”,windows批次/powershell

好吧,我知道這是一個棘手的問題。我有一個軟體可以在網路中的所有電腦上運行驗證腳本。我也可以創建自己的腳本。但我發現一個問題,該腳本以具有管理員權限的特定用戶身份運行。因此,當我的腳本檢查登錄路徑時: Computer\HKEY_CURRENT_USER 實際上並不是登入使用者的註冊表,而是用於執行腳本的使用者。

有沒有辦法在其他登入使用者中執行命令 reg.exe(無需密碼)?

到目前為止正在嘗試:

:: Get the current console logged user 
for /F "tokens=1" %%f in ('query user ^| find "Active"') do set "ConsoleUser=%%f" 
:: clear the ">" character that sometimes is on the left of the user 
set ConsoleFinal=%ConsoleUser:*>=% 
:: enter the user folder (* at the end, if the user is part of a domain)  
cd c:\users\%ConsoleUser%*  
:: Import the other user registry reg load HKU\test ntuser.dat

但後來我收到了 ntuser.dat 正在使用的錯誤(那是因為其他使用者已登入)

在簡歷中:我需要檢查當前用戶的註冊表項,但來自在不同用戶上運行的腳本。

答案1

如果用戶登錄,他們的註冊表將已經安裝到HKEY_USERS/%SID%.

在 powershell 中,您可以設定到 HKEY_USERS 的映射,然後存取那裡的註冊表。如果我想獲取“系統”帳戶的 Conhost 設置,我可以這樣做。

PS > New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS
PS > Get-ItemProperty HKU:\S-1-5-18\Console\

相關內容