html - How to launch a network printer install from a print server via locally hosted webpage (IIS)? - Stack Overflow

I have used Ai to create a webpage with buttons listing each printer. I cannot get the buttons to insta

I have used Ai to create a webpage with buttons listing each printer. I cannot get the buttons to install the correlated printer from the print server. I tried a powershell script and the script works if launched from the machine but not from the button. Not sure if there is a better way to do this. Any input would be greatly appreciated.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Berry Aviation's Printers</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            margin: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            height: 100vh;
        }
        .button-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 10px;
            width: 90%;
            max-width: 1200px;
            flex-grow: 1;
        }
        .printer-button {
            padding: 20px;
            font-size: 18px;
            cursor: pointer;
            border: none;
            background-color: #007bff;
            color: white;
            border-radius: 5px;
            width: 100%;
            height: 100%;
            min-height: 60px;
        }
        .printer-button:hover {
            background-color: #0056b3;
        }
        .instruction-text {
            font-size: 20px;
            margin-top: 10px;
            max-width: 600px;
        }
    </style>
</head>
<body>
    <h1>Berry Aviation's Printers</h1>
    <p class="instruction-text">To map a printer to your machine, please click on the applicable printer.</p>
    <div class="button-container" id="printerButtons"></div>

    <script>
        const printers = [
            "Amentum Office - Kyocera Taskalfa 3554ci",
            "Corp Saftey 6",
            "Corp-Accounting(Leah)-HPColorM283",
            "Corp-Accounting-Ecosys M3645idn",
            "Gov't Services - Kyocera TASKalfa 3552ci",
            "Corp-IT-HP Color M479",
            "FBO Line Supervisor Office - HP Laserjet M281fdw",
            "FBO-Admin -Veronica",
            "FBO-FrontDesk-Ecosys M2640idw",
            "Hangar 1-2 Floating Platform Eric- Canon MF656CDW",
            "Hangar 1-2 Floor - Kyocera Taskalfa 3554ci",
            "Hangar 1-2-Floating Platform 1- Canon MF650C Series",
            "Hangar 3 Floor 45",
            "Hangar GSEM 44",
            "Hangar#1/2 Component Shop - Brother MFC-L9570CDW series",
            "Hanger 1/2 - .10 - Zebra ZD421",
            "Hanger1-Component-Zebra421-Orange",
            "Hanger1-Floor-Brother MFC-L9570CDW",
            "HYI-PRINT-01",
            "Kitchen - Canon iR-ADV C3935",
            "MX Hangar - Kyocera TASKalfa 3554ci",
            "MX Office Main - Kyocera TASKalfa 3554ci KX",
            "MX Parts Label - Zebra ZT410-203dpi ZPL",
            "MX Parts Orange Label - Zebra ZT411-203dpi ZPL",
            "MX Receiving - Canon C359iF",
            "MX Records - Kyocera:ECOSYS M3550idn:KM49DD7B",
            "MX Shipping - Canon C359iF",
            "MX-Counter-EcosysP3145dn",
            "MX-PartsHallway-Ecosys M3145idn",
            "Redbird Cubicle Area -Canon C359iF",
            "RedBird Training 64",
            "Redbird-AdminAS- LaserJet Pro MFP 4101fdw",
            "RedBird-AdminAs2-HPNeverStop1001w (HP Neverstop Laser 1001nw)",
            "RedBird-CRO_SHOP-Taskalfa 3554ci",
            "RedBird-Dispatch-Brother L5850",
            "Redbird-MRO Norma-HP M283fdw",
            "RedBird-MRO-CRO-ZD421",
            "RedBird-MRO-CRO-ZT411",
            "Training- ClassRoom#2-Brother MFC-L3770",
            "Training-BreakRm-HPOffJet8620",
            "Training-Front-TASKalfa 5054ci KX"
        ];

        const container = document.getElementById("printerButtons");
        
        printers.forEach(printer => {
            const button = document.createElement("button");
            button.classList.add("printer-button");
            button.textContent = `Install ${printer}`;
            button.onclick = () => {
                const script = `powershell.exe -Command "Add-Printer -ConnectionName '\\\\ba-print\\${printer}'; Write-Host 'Printer ${printer} has been successfully added from \\\\ba-print\\' -ForegroundColor Green"`;
                window.location.href = `data:text/plain;charset=utf-8,${encodeURIComponent(script)}`;
            };
            container.appendChild(button);
        });
    </script>
</body>
</html>

I have used Ai to create a webpage with buttons listing each printer. I cannot get the buttons to install the correlated printer from the print server. I tried a powershell script and the script works if launched from the machine but not from the button. Not sure if there is a better way to do this. Any input would be greatly appreciated.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Berry Aviation's Printers</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            margin: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            height: 100vh;
        }
        .button-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 10px;
            width: 90%;
            max-width: 1200px;
            flex-grow: 1;
        }
        .printer-button {
            padding: 20px;
            font-size: 18px;
            cursor: pointer;
            border: none;
            background-color: #007bff;
            color: white;
            border-radius: 5px;
            width: 100%;
            height: 100%;
            min-height: 60px;
        }
        .printer-button:hover {
            background-color: #0056b3;
        }
        .instruction-text {
            font-size: 20px;
            margin-top: 10px;
            max-width: 600px;
        }
    </style>
</head>
<body>
    <h1>Berry Aviation's Printers</h1>
    <p class="instruction-text">To map a printer to your machine, please click on the applicable printer.</p>
    <div class="button-container" id="printerButtons"></div>

    <script>
        const printers = [
            "Amentum Office - Kyocera Taskalfa 3554ci",
            "Corp Saftey 6",
            "Corp-Accounting(Leah)-HPColorM283",
            "Corp-Accounting-Ecosys M3645idn",
            "Gov't Services - Kyocera TASKalfa 3552ci",
            "Corp-IT-HP Color M479",
            "FBO Line Supervisor Office - HP Laserjet M281fdw",
            "FBO-Admin -Veronica",
            "FBO-FrontDesk-Ecosys M2640idw",
            "Hangar 1-2 Floating Platform Eric- Canon MF656CDW",
            "Hangar 1-2 Floor - Kyocera Taskalfa 3554ci",
            "Hangar 1-2-Floating Platform 1- Canon MF650C Series",
            "Hangar 3 Floor 45",
            "Hangar GSEM 44",
            "Hangar#1/2 Component Shop - Brother MFC-L9570CDW series",
            "Hanger 1/2 - .10 - Zebra ZD421",
            "Hanger1-Component-Zebra421-Orange",
            "Hanger1-Floor-Brother MFC-L9570CDW",
            "HYI-PRINT-01",
            "Kitchen - Canon iR-ADV C3935",
            "MX Hangar - Kyocera TASKalfa 3554ci",
            "MX Office Main - Kyocera TASKalfa 3554ci KX",
            "MX Parts Label - Zebra ZT410-203dpi ZPL",
            "MX Parts Orange Label - Zebra ZT411-203dpi ZPL",
            "MX Receiving - Canon C359iF",
            "MX Records - Kyocera:ECOSYS M3550idn:KM49DD7B",
            "MX Shipping - Canon C359iF",
            "MX-Counter-EcosysP3145dn",
            "MX-PartsHallway-Ecosys M3145idn",
            "Redbird Cubicle Area -Canon C359iF",
            "RedBird Training 64",
            "Redbird-AdminAS- LaserJet Pro MFP 4101fdw",
            "RedBird-AdminAs2-HPNeverStop1001w (HP Neverstop Laser 1001nw)",
            "RedBird-CRO_SHOP-Taskalfa 3554ci",
            "RedBird-Dispatch-Brother L5850",
            "Redbird-MRO Norma-HP M283fdw",
            "RedBird-MRO-CRO-ZD421",
            "RedBird-MRO-CRO-ZT411",
            "Training- ClassRoom#2-Brother MFC-L3770",
            "Training-BreakRm-HPOffJet8620",
            "Training-Front-TASKalfa 5054ci KX"
        ];

        const container = document.getElementById("printerButtons");
        
        printers.forEach(printer => {
            const button = document.createElement("button");
            button.classList.add("printer-button");
            button.textContent = `Install ${printer}`;
            button.onclick = () => {
                const script = `powershell.exe -Command "Add-Printer -ConnectionName '\\\\ba-print\\${printer}'; Write-Host 'Printer ${printer} has been successfully added from \\\\ba-print\\' -ForegroundColor Green"`;
                window.location.href = `data:text/plain;charset=utf-8,${encodeURIComponent(script)}`;
            };
            container.appendChild(button);
        });
    </script>
</body>
</html>

Share Improve this question asked Mar 24 at 21:50 gearhead87gearhead87 11
Add a comment  | 

1 Answer 1

Reset to default -2

Historically, at least, you can install printers from a website via cab files. This is the standard model offered by Windows IPP. An auto-generated install webpage is generated if you use the IPP role.

You can probably generate a ps1 file on the fly with a data URI. Your sample doesn't have anything to imply to the user agent that it is a ps1 file. You might correct that by adding a download attribute to an <a> tag to give a suggested filename, or by using the name= attribute. Support for each of these varies by browser.

Example:

<a download='Hello.ps1' href='data:application/octet-stream,Write-Host%20%22Hello%2C%20World%21%22%0D%0ARead-Host%20%22Press%20any%20key%20to%20continue%E2%80%A6%22%0D%0A'>Hello world</a>

or

<a href='data:application/octet-stream;name=hello.ps1,Write-Host%20%22Hello%2C%20World%21%22%0D%0ARead-Host%20%22Press%20any%20key%20to%20continue%E2%80%A6%22%0D%0A'>Hello world</a>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744226880a4564050.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信