hardexit
Goto Top

Netzwerkdrucker installieren, vb.net

Hallo Leute,

also nach langem Tüfteln habe ich jetzt einen Funktionierenden Drucker installationscode, den ich gerne mit euch teilen will. :D

    'Deklaration: Installations Button Drucker  
    Private Sub InstallationDrucker_Click(sender As Object, e As EventArgs) Handles InstallationDrucker.Click
        Dim pprnport As New Process
        Dim pprintui As New Process
        Statusbox.Text = ("Installation gestartet")  

        If System.Environment.Is64BitOperatingSystem = True Then
            OSArch = ("x64")  
        Else
            OSArch = ("i386")  
        End If

        Dim Menge As Integer = DataGridDrucker.Rows.Count - 1
        For i = 0 To Menge
            If CBool(DataGridDrucker.Rows(i).Cells(4).Value) = True Then
                Dim DruckerIP = DataGridDrucker.Rows(i).Cells(0).Value
                Dim DruckerName = DataGridDrucker.Rows(i).Cells(2).Value
                Dim DruckerPath = DataGridDrucker.Rows(i).Cells(3).Value

                Dim DruckerIP2 = ControlChars.Quote & "IP_" & DruckerIP & ControlChars.Quote  
                Dim DruckerName2 = ControlChars.Quote & DruckerName & " (" & i & ")" & ControlChars.Quote  
                Dim DruckerName3 = ControlChars.Quote & DruckerName & ControlChars.Quote
                Dim DruckerPath2 = ControlChars.Quote & DruckerPath & OSArch & "\oemsetup.inf " & ControlChars.Quote  

                pprnport.StartInfo.WorkingDirectory = "C:\WINDOWS\system32\"  
                pprnport.StartInfo.FileName = "C:\WINDOWS\system32\cscript.exe"  
                pprnport.StartInfo.Arguments = "C:\WINDOWS\system32\Printing_Admin_Scripts\de-DE\prnport.vbs -a -r " & DruckerIP2 & " -h " & DruckerIP & " -o raw -n 9100"  
                pprnport.StartInfo.WindowStyle = ProcessWindowStyle.Normal
                pprnport.StartInfo.Verb = "runas"  
                pprnport.Start()
                pprnport.WaitForExit()

                pprintui.StartInfo.WorkingDirectory = "C:\WINDOWS\system32\"  
                pprintui.StartInfo.FileName = "C:\WINDOWS\system32\rundll32.exe"  
                pprintui.StartInfo.Arguments = "printui.dll,PrintUIEntry /if /b " & DruckerName2 & " /f " & DruckerPath2 & " /r " & DruckerIP2 & " /m " & DruckerName3 & " /Y"  
                pprintui.StartInfo.WindowStyle = ProcessWindowStyle.Normal
                pprintui.StartInfo.Verb = "runas"  
                pprintui.Start()
                pprintui.WaitForExit()
                MsgBox("Drucker installiert: " & DruckerName)  
            End If
        Next
        Statusbox.Text = ("Alle Drucker wurden installiert")  
    End Sub

Content-ID: 283058

Url: https://administrator.de/contentid/283058

Ausgedruckt am: 25.11.2024 um 17:11 Uhr