2026-02-03

Open "Find Printers" by Hyperlink



Microsoft Edge

# AutoOpenFileTypes: qds
GPO: Computer Configuration → Administrative Templates → Microsoft Edge → List of file types that should be automatically opened on download
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenFileTypes" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenFileTypes" -Name "1" -Value "qds" -PropertyType String -Force | Out-Null

# AutoOpenAllowedForURLs: 只允許 intranet.contoso.com
GPO: Computer Configuration → Administrative Templates → Microsoft Edge → URLs where AutoOpenFileTypes can apply
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenAllowedForURLs" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenAllowedForURLs" -Name "1" -Value "intranet.contoso.com" -PropertyType String -Force | Out-Null
          Verify: edge://policy


Google Chrome

# AutoOpenFileTypes: qds
GPO: Computer Configuration → Administrative Templates → Google → Google Chrome → List of file types that should be automatically opened on download
New-Item -Path "HKLM:\SOFTWARE\Policies\Google\Chrome\AutoOpenFileTypes" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Google\Chrome\AutoOpenFileTypes" -Name "1" -Value "qds" -PropertyType String -Force | Out-Null

# AutoOpenAllowedForURLs: 只允許 intranet.contoso.com
GPO: Computer Configuration → Administrative Templates → Google → Google Chrome → URLs where AutoOpenFileTypes can apply
New-Item -Path "HKLM:\SOFTWARE\Policies\Google\Chrome\AutoOpenAllowedForURLs" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Google\Chrome\AutoOpenAllowedForURLs" -Name "1" -Value "intranet.contoso.com" -PropertyType String -Force | Out-Null

          Verify: edge://policy


.PHP (Script by Copilot)

<?php
// download-qds.php
// 目的:強制讓瀏覽器下載 .qds,而不是顯示內容;並避免 MIME sniffing。

// 你的 qds 實體檔案位置(建議放 webroot 外)
$qdsFile = 'FindPrinters.qds';

// 使用者看到/下載的檔名
$downloadName = 'FindPrinters.qds';

// 基本檔案檢查
if (!is_file($qdsFile) || !is_readable($qdsFile)) {
    http_response_code(404);
    header('Content-Type: text/plain; charset=utf-8');
    echo "QDS file not found.";
    exit;
}

// 清除可能已經輸出的內容,避免 header 送出失敗
if (ob_get_level()) {
    ob_end_clean();
}

// 1) Content-Disposition: attachment => 指示瀏覽器以「下載」處理,而非 inline 顯示 [1](https://www.reddit.com/r/PowerShell/comments/4cjdk8/get_the_ad_site_name_of_a_computer/)
header('Content-Disposition: attachment; filename="' . $downloadName . '"');

// 2) Content-Type: application/octet-stream => 常用於「未知/任意二進位」並偏向保存到磁碟 [2](https://stackoverflow.com/questions/78334710/best-powershell-method-to-get-the-current-active-directory-site-name-of-the-loca)
header('Content-Type: application/octet-stream');

// 3) X-Content-Type-Options: nosniff => 要求瀏覽器不要靠內容猜 MIME type,避免被當成 text/plain 顯示 [3](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc731935%28v=ws.11%29)[4](https://zaur.it/know-your-domain-mastering-the-nltest-command/)
header('X-Content-Type-Options: nosniff');

// 其他建議(可選):避免快取、加上長度(某些環境下載體驗更好)
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Content-Length: ' . filesize($qdsFile));

// 輸出檔案
readfile($qdsFile);
exit;
?>





沒有留言:

張貼留言