SIMPLE_XP Posted May 15, 2007 Posted May 15, 2007 Well I am having some minor trouble converting the follow VBScript code to AutoIT. No matter how I format the SERVER, PRINTER variables after "oMaster.PrinterDel" I get an error. I can get the Add printer code to work, just not the delete! VBscript CODEset oMaster = CreateObject("PrintMaster.PrintMaster.1") oMaster.PrinterDel ServerName, PrinterName AutoIT Code... so far I have tried... oMaster.PrinterDel $PRINTSERVER_NAME, $PRINTER_NAME oMaster.PrinterDel($PRINTSERVER_NAME, $PRINTER_NAME) oMaster.PrinterDel('"' & $PRINTSERVER_NAME & "," & '"' & $PRINTER_NAME & '"') oMaster.PrinterDel '"' & $PRINTSERVER_NAME & "," & '"' & $PRINTER_NAME & '"' oMaster.PrinterDel $PRINTSERVER_NAME & "," & $PRINTER_NAME CODEFunc REMOVE_PRINT_QUEUE($PRINTSERVER_NAME, $PRINTER_NAME) $P_OBJ_MASTER = ObjCreate("PrintMaster.PrintMaster.1") $P_OBJ_MASTER.PrinterDel($PRINTSERVER_NAME, $PRINTER_NAME) EndFunc Any help would be appreciated. Thanks! Hero's Dawn, an RPG Adventure completely coded in AutoITwmifunctions UDF, WMI UDF
DaleHohm Posted May 15, 2007 Posted May 15, 2007 You might want to show the error you receive. Also, what are you passing in for server and printer? If it is the local server you may want to try the keyword Default (not "Default", but Default) for the server name. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
PsaltyDS Posted May 15, 2007 Posted May 15, 2007 CODEset oMaster = CreateObject("PrintMaster.PrintMaster.1") oMaster.PrinterDel ServerName, PrinterNameAssuming this works in VBS (does it?), you don't show how ServerName and PrinterName were defined in the VBS version. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
SIMPLE_XP Posted May 15, 2007 Author Posted May 15, 2007 Assuming this works in VBS (does it?), you don't show how ServerName and PrinterName were defined in the VBS version. Sorry guys, I just assumed the Variable names were self explanitory. I am passing the Name of the server and Name of the printer (remotely) so the server variable would be "\\MYSERVER1" and Printer variable would be "PRINTER2".I looked at how the add method worked and figured out that the VBScript code from Microxoft was incorrect (Whitepaper from MS "prnadmin.doc" comes with Toolkit) and here is what finally worked.CODEFunc REMOVE_PRINT_QUEUE($PRINTSERVER_NAME, $PRINTER_NAME) $P_OBJ_PRINTER.ServerName = "\\" & $PRINTSERVER_NAME $P_OBJ_PRINTER.PrinterName = $PRINTER_NAME $P_OBJ_MASTER.PrinterDel($P_OBJ_PRINTER) $PRINTSERVER_NAME = "" $PRINTER_NAME = "" EndFunc Hero's Dawn, an RPG Adventure completely coded in AutoITwmifunctions UDF, WMI UDF
ptrex Posted May 15, 2007 Posted May 15, 2007 @all just for the fun of it. expandcollapse popupdim $oMaster dim $oDriver ;The following code creates the required PrintMaster and Driver objects. $oMaster = ObjCreate("PrintMaster.PrintMaster.1") $oDriver = ObjCreate("Driver.Driver.1") ;The following code sets the driver name. It is required and the string cannot be empty. $oDriver.ModelName = "HP LaserJet 4300 PCL6" ;The following code sets the driver processor. You must use either Intel or Itanium. $oDriver.DriverArchitecture = "Intel" ;The following code specifies the operating system version for which the driver was written. If this setting is ;not configured, the caller's environment is used. You can use one of the following sets of values: ;"Windows 95, Windows 98, and Windows Millennium Edition" ;"Windows NT 4.0 or 2000" ;"Windows 2000, Windows XP and Windows Server 2003" ;"Windows XP and Windows Server 2003" $odriver.DriverVersion = "Windows NT" ;The following code sets the driver cache. This setting is optional. $oDriver.Path = "c:\temp" ;The following code sets the INF file. This setting is optional because if it is not set, the default directory, ;%windir%\inf\ntprint.inf, is used. $oDriver.InfFile = "\\stmsr05\Support\Printers\Hp 4300 PCL6\hpc4300c.inf" ;The following code sets a server name to add a driver remotely. If you do not specify a ServerName, or if ;you use empty double quotes (""), the default, which adds a driver to the local computer, is used. $oDriver.ServerName = "" ;The following code adds the driver. $oMaster.DriverAdd ($oDriver) ;The following code uses the Err object to determine whether the driver was created successfully. if @error <> 0 then ConsoleWrite("An error occurred") endif regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now