Gewusst wie: hinzufügen eines Lokalen Druckers mithilfe von VBScript auf Windows 7?
Ich habe einen Windows 7 64bit pc, ich bin versucht, einen Lokalen Drucker hinzufügen, die automatisch den Treiber installiert und den Drucker freigegeben, wenn es fertig ist.
Der Hafen ist ein Loopback-IP-Adresse (127.0.0.1), und er nutzt das Zebra (ZDesigner LP 2844) Treiber. (Das können Sie hier bekommen: http://www.zebra.com/us/en/support-downloads/desktop/lp-2844.html )
Meine aktuelle Skript funktioniert Super auf XP, aber nicht so gut auf Windows 7. Es kommt mit dem Fehler
"Microsoft VBScript runtime error:ActiveX-Komponente kann nicht Objekt erstellen: 'Port.Port.1' für mein script AddPort.vbs
Dem folgenden Skript wird aufgerufen, AddPort.vbs
'ADDING:
dim oPort
dim oMaster
set oPort = CreateObject("Port.Port.1")
set oMaster = CreateObject("PrintMaster.PrintMaster.1")
wscript.echo "Adding port to local machine...."
'Indicate where to add the port. Double quotes ("" ) stand for the local computer, which is the default, or put "\\servername"
oPort.ServerName = ""
'The name of the port cannot be omitted.
oPort.PortName = "CustomPortName"
'The type of the port can be 1 (TCP RAW), 2 (TCP LPR), or 3 (standard local).
oPort.PortType = 3
'For TCP RAW ports. Default is 9100.
oPort.PortNumber = 9101
'Try adding the port.
oMaster.PortAdd oPort
'Test for the status.
If Err <> 0 then
wscript.echo "Error " & Err & " occurred while adding port"
End If
Dem Folgenden Skript wird aufgerufen, AddPrinter.vbs
Dieses Skript zeigt die Fehlermeldung "Microsoft VBScript runtime error:ActiveX-Komponente kann Objekt nicht erstellen: PrintMaster.PrintMaster.1
' Adding a Printer
' The sample code in this section creates any required objects, adds a printer to a remote server, and configures some driver and port information.
dim oMaster
dim oPrinter
wscript.echo "Adding VirtualPrinter printer to local machine...."
'The following code creates the required PrintMaster and Printer objects.
set oMaster = CreateObject("PrintMaster.PrintMaster.1")
set oPrinter = CreateObject("Printer.Printer.1")
'The following code specifies the name of the computer where the printer will be added. To specify the local
'computer, either use empty quotes (“”) for the computer name, or do not use the following line of code. If
'ServerName is not set, the local computer is used. Always precede the name of a remote computer with two backslashes (\\).
oPrinter.ServerName = ""
'The following code assigns a name to the printer. The string is required and cannot be empty.
oPrinter.PrinterName = "VirtualPrinter"
'The following code specifies the printer driver to use. The string is required and cannot be empty.
oPrinter.DriverName = "ZDesigner LP 2844"
'The following code specifies the printer port to use. The string is required and cannot be empty.
oPrinter.PortName = "LoopBack"
'The following code specifies the location of the printer driver. This setting is optional, because by default
'the drivers are picked up from the driver cache directory.
'oPrinter.DriverPath = "c:\drivers"
'The following code specifies the location of the INF file. This setting is optional, because by default the INF
'file is picked up from the %windir%\inf\ntprint.inf directory.
'oPrinter.InfFile = "c:\winnt\inf\ntprint.inf"
oPrinter.PrintProcessor = "winprint"
'The following code adds the printer.
oMaster.PrinterAdd oPrinter
'The following code uses the Err object to determine whether the printer was added successfully.
if Err <> 0 then
wscript.echo "Error " & Err & " occurred while adding VirtualPrinter"
else
wscript.echo "Printer added successfully"
end if
' To configure other printer settings, such as comments, create a Printer object and then call PrintMaster's method PrinterSet.
wscript.echo "Configuring printer...."
oPrinter.Comment = "Virtual printer to capture labels"
oPrinter.ShareName = "VirtualPrinter"
oPrinter.Shared = true
oPrinter.Local = true
oMaster.PrinterSet oPrinter
if Err <> 0 then
wscript.echo "Error " & Err & " occurred while changing settings for VirtualPrinter"
end if
Gibt es eine andere Möglichkeit kann ich erstellen Sie einen Lokalen Drucker, der Treiber, Port-Nummer und Port-Name und Freigabename und Drucken Prozessor mit vbscript in Windows 7???
Danke im vorraus, die beste Antwort erhalten Punkte.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Dies ist genau das, was Sie brauchen, für Windows 7:
Den sieben Drucker-Dienstprogramme später sehen werden, befinden sich in der
C:\Windows\System32\Printing_Admin_Scripts\en-US
Ordner, die nicht im Pfad aufgeführt. Daher muss man tatsächlich ändern Sie in diesem Ordner in Bezug auf die Ausführung der Dienstprogramme. Und da diese Dienstprogramme sind entworfen, um von der Befehlszeile aus ausgeführt, müssen Sie starten Sie vom Eingabeaufforderungsfenster, und führen Sie mithilfe von Windows Script Host command-line-based script host (Cscript.exe
).Windows 7 VBScript-Druck-utilities
Hoffe, das funktioniert für Sie
Ich einen anderen Weg gefunden, zu automatisieren hinzufügen des Druckers, zuerst erstellte ich eine batch-Datei, dann habe ich die prnmngr.vbs kommt mit Windows 7 automatisch fügen Sie die Drucker, für mich. Für diese Arbeit hatte ich bereits die Zebra-Treiber auf dem Computer installiert ist (aber das Konzept wäre das gleiche für jede andere Art von Drucker). Dann habe ich die batch-Datei ausgeführt.
Folgenden sehen Sie, wie ich es gemacht habe, ich habe die batch-Datei text hier:
Name der Datei: AddPrinter.bat
Passen diese können Sie nutzen diese websites als Referenz;
http://technet.microsoft.com/en-us/library/cc725868(v=ws.10).aspx
http://technet.microsoft.com/en-us/library/bb490974.aspx
http://blog.ogwatermelon.com/?p=3489
http://winadminnotes.wordpress.com/2010/02/19/how-to-manage-printers-and-printer-drivers-remotely-from-command-line/
http://technet.microsoft.com/en-us/library/cc754352(v=ws.10).aspx