我創建了一個資料庫,您必須在第一次打開它時更改主密鑰,在此更改之後,不應再更改主密鑰。為了實現這一點,我創建了這個批次檔:
@CD /d "%~dp0"
KeePass-2.42.1-Setup.exe /verysilent
REM Installs KeePass 2.42.1 very silent
COPY KeePass.config.xml "C:\Program Files (x86)\KeePass Password Safe 2\"
REM Recplaces the Configuration File with a modified file. Modification are:
REM -Setting UIFLAG to 35
REM -CheckForUpdate to false and CheckForUpdateConfigured to true
REM - <Policy> <NewFile> to false
COPY Datenbank.kdbx "D:\Eigene Dateien\KeePass\"
REM Copies the modified Database onto the PC, this Database asks for a change of the masterkey the first time it gets opened
ECHO "Please open the database PasswortManager on your Desktop now, change the masterkey as prompted, save it and close Keepass. Press Enter after finishing"
PAUSE
COPY KeePass2.config.enforced.xml "C:\Program Files (x86)\KeePass Password Safe 2\"
REM Replaces the configuration file again this time with <ChangeMasterKey> to False
程式碼的某些部分被刪除,因為它們更改了與我的問題無關的設定。
這種方法有效,但感覺很奇怪,而且有很多方法可能會導致問題。例如,如果他們在開啟資料庫之前按 Enter 鍵,或在 keepass 仍處於開啟狀態時按 Enter 鍵。有沒有辦法只允許第一個主密碼更改?無需多次覆蓋配置。
如果我可以改進我的問題,請告訴我並感謝您的幫助
編輯:在用戶的建議之後,我將第二個設定檔更改為強制並正在使用它。看來我還是繼續用雙設定檔吧。