Jump to content

gshaw

Members
  • Posts

    5
  • Joined

  • Last visited

gshaw's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Tried to do that but the converter failed so went for other avenues... In the end I found "rundll printui.dll" from a batch file did the trick... called it from AutoIt using RunAs and it did the job perfectly Also had to code in a VBS popup box to act as a splash screen while the driver installation was going on but eventually it's all doing what it's meant to and solves the problem so result! Thanks for the advice and info
  2. Edit: just found why that didn't work... forum removed all the slashes from the path! Got it working but still received the same error when the script tried to run... access denied on line 25 For reference here's the vbscript it's trying to run... My guess is that somewhere in the vbscript it's using the credentials of the currently logged-on user rather than the one that called the script i.e. the autoit RunAs user? PrnName = "StudyScan Printer" PrnLocation = "Reception" PrnComment = "Printer for StudyScan software" PrnDrv = "HP LaserJet 4" DrvPath = "C:\WINDOWS\system32\spool\drivers\w32x86\3" InfPath = DrvPath & "\UNIDRV.DLL" PortIP = "10.10.10.10" PortName = "IP_" & PortIP strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") '''''''''''''''''''''''''' ' create ip-printer-port '''''''''''''''''''''''''' Set objNewPort = objWMIService.Get _ ("Win32_TCPIPPrinterPort").SpawnInstance_ objNewPort.Name = PortName objNewPort.Protocol = 1 objNewPort.HostAddress = PortIP objNewPort.PortNumber = "9100" objNewPort.SNMPEnabled = False objNewPort.Put_ ' wsh.echo "port created" '''''''''''''''''''''''''' ' install printer driver '''''''''''''''''''''''''' ' If the driver is not signed, one cannot use WMI scripting ' to install the driver. ' Make sure the cat file for the package is copied to the same ' location as the driver objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True Set objDriver = objWMIService.Get("Win32_PrinterDriver") objDriver.Name = PrnDrv objDriver.SupportedPlatform = "Windows NT x86" objDriver.Version = "3" objDriver.DriverPath = DrvPath objDriver.Infname = InfPath intResult = objDriver.AddPrinterDriver(objDriver) ' wsh.echo "driver installed" '''''''''''''''''''''''''' ' Add local printer '''''''''''''''''''''''''' Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ objPrinter.DriverName = PrnDrv objPrinter.PortName = PortName objPrinter.DeviceID = PrnName objPrinter.Location = PrnLocation objPrinter.Comment = PrnComment objPrinter.Network = True objPrinter.Put_ ' wsh.echo "printer added"
  3. Just gave it a go but only saw a brief flicker of a CMD window pop up and then disappear?
  4. The directory should definitely be accessible, tried it with a high level account that should be able to access all areas! The script fails at line 25, where it starts to try and add the port so it seems somehow the script isn't getting the admin privileges even though the wscript is?
  5. Been trying to do this for ages now and it's driving me nuts! Basically we've got an old 16-bit app that can only print to a local IP printer... which needs admin rights to map. I've got a VBS script I found to do it and want to use AutoIt to run the VBS with elevated rights and then compile to an EXE to hide the credentials. Found this... RunAs("USERNAME", "DOMAIN", "PASSWORD", 0, 'wscript.exe "' & @ScriptDir & '\print.vbs"') But when compiled and run I get wscript access denied error?! The wscript process is running as the admin account I put in the gaps above so what's going on?
×
×
  • Create New...