透過 Telnet 或 SSH 遠端登入 Windows 伺服器時,預設工作目錄若非 C:\Documents and Settings\Administrator,執行腳本、批次檔常因路徑錯誤失敗。透過修改登錄表中使用者設定檔路徑,即可統一預設目錄。
登入後提示:
C:\Documents and Settings\anywolfs.com>
而非預期的:
C:\Documents and Settings\Administrator>
regedit。HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileListS-1-5-21-...-500),找到 ProfileImagePath (類型 REG_EXPAND_SZ) 值為目前錯誤路徑 (如 %SystemDrive%\Documents and Settings\anywolfs.com) 的那一組 SID。ProfileImagePath 值修改為:%SystemDrive%\Documents and Settings\Administratorcmd),觀察提示字元顯示的路徑 (如 C:\Documents and Settings\anywolfs.com)。ProfileList 下各 SID 中,找 ProfileImagePath 等於該路徑的項目,即為目標 SID。注意:修改前請匯出該 SID 分支備份。Telnet 傳輸明文,生產環境建議改用 SSH (OpenSSH for Windows),並搭配金鑰認證、防火牆限制來源 IP,確保遠端管理安全。