不好意思,請教大家。
    自己寫了一個 .bat 的批次檔,
    嘗試讀取 regedit 內的某些欄位
    例如:
    reg query HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ > test.txt
    單純用 cmd 執行這個批次檔,
    執行結果可以正常產出 test.txt 
    且檔案內容也是正確資訊(如下)
    HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Firefox
    HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\MaintenanceService
    HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox
    HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox 97.0.2
    但是若利用 WinRAR 設定成 自解檔(.exe)
    並執行這個 批次檔,
    結果卻是 空白
    請教各位,該如何排除此問題。
    
    謝謝大家。
    
    不好意思,補充一下 WinRAR 的參數設定資訊如下:
    Path=C:\Windows\SoftwareDistribution\Download
    Setup=C:\Windows\SoftwareDistribution\Download\Setup\Start.bat
    Silent=1
    Overwrite=1
    
    其中 Start.bat 的內容就是上述的
    reg query HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ > test.txt
    
    謝謝
set "SystemPath=%SystemRoot%\System32"
if exist "%SystemRoot%\Sysnative\cmd.exe" set "SystemPath=%SystemRoot%\Sysnative"
%SystemPath%\reg query HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ > test.txt
因為自解檔的bat執行於32bit的cmd.exe
請參考
Why does a batch file executed from a WinRAR SFX not work on accessing hosts file? - Stack Overflow