mithandir1 Posted June 8, 2015 Share Posted June 8, 2015 (edited) This is part of script to help streamline printer installation in my office. We have multiple printers that all use the same drivers. The only only difference is the printers IP and a descriptive name. The script is compiled and is in the parent directory(named PrinterInstaller) that contains subdirectories containing 32 and 64 bit dirvers. I would like to make this folder "portable" so that it will run correctly no matter where on the hard drive it is placed. Currently it must be placed on C:\. If i replace "C:\PrinterInstaller" with @scriptdir and "\"Windows gives me an error. Also if the rename the folder Printer Installer(with a space) and change the script to match I get an error from windows.Run(@ComSpec & " /c " & 'rundll32 printui.dll,PrintUIEntry /if /b "' & $name & '" /f C:\PrinterInstaller\' & $bit & '\oemsetup.inf /r "IP_' & $ip & '" /m "PCL6 Driver for Universal Print"', "", @SW_HIDE) Edited June 8, 2015 by mithandir1 Link to comment Share on other sites More sharing options...
javiwhite Posted June 8, 2015 Share Posted June 8, 2015 Try putting this in your script, right above the run command, Then once the script exits, Paste whatever is on clipboard to notepad and debug whatever is being parsed to cmd.ClipPut(@ComSpec & " /c " & 'rundll32 printui.dll,PrintUIEntry /if /b "' & $name & '" /f ' & @ScriptDir & '\PrinterInstaller\' & $bit & '\oemsetup.inf /r "IP_' & $ip & '" /m "PCL6 Driver for Universal Print"')CheersJavi give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime. Link to comment Share on other sites More sharing options...
mithandir1 Posted June 8, 2015 Author Share Posted June 8, 2015 Well that was a good idea but I get this: error: ClipPut() [built-in] called with wrong number of args. Link to comment Share on other sites More sharing options...
Jewtus Posted June 8, 2015 Share Posted June 8, 2015 (edited) Easier way... ConsoleWrite the line and a @CRLFConsoleWrite(@ComSpec & " /c " & 'rundll32 printui.dll,PrintUIEntry /if /b "' & $name & '" /f ' & @ScriptDir & '\PrinterInstaller\' & $bit & '\oemsetup.inf /r "IP_' & $ip & '" /m "PCL6 Driver for Universal Print"'&@CRLF)I use this when testing command line. I put a msg box up after the console write to validate the syntax first. I'd also suggest Using ' instead of " to start your comspec... the reason I say that is " is required for most CMDs and ' wont work. Edited June 8, 2015 by Jewtus mithandir1 1 Link to comment Share on other sites More sharing options...
javiwhite Posted June 8, 2015 Share Posted June 8, 2015 Mithandir1, Really? Because running the code exactly as it is in my previous comment works fine. Did you copy the code from my comment? Or wrap your run function in a ClipPut?Copy the code in my previous comment and insert it.Alternatively, you can use:ClipPut('rundll32 printui.dll,PrintUIEntry /if /b "' & $name & '" /f ' & @ScriptDir & '\PrinterInstaller\' & $bit & '\oemsetup.inf /r "IP_' & $ip & '" /m "PCL6 Driver for Universal Print"')and then paste directly into cmd and run.ConsoleWrite will work as Jewtus suggested, I just prefer using the clipboard for debugging external code, as it means you can run the code to emulate the script, And identify where the external command is failing.Neither way has a significant benefit over the other, It's just down to personal preference really.Cheers Javi mithandir1 and Jewtus 2 give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime. Link to comment Share on other sites More sharing options...
mithandir1 Posted June 8, 2015 Author Share Posted June 8, 2015 (edited) Thanks guys. Now that I can see the command I think I have it figured out. Quotation marks are needed around the file location when there is a space.Run(@ComSpec & " /c " & 'rundll32 printui.dll,PrintUIEntry /if /b "' & $name & '" /f "' & @ScriptDir & '\' & $bit & '\oemsetup.inf" /r "IP_' & $ip & '" /m "PCL6 Driver for Universal Print"', "", @SW_HIDE) Edited June 8, 2015 by mithandir1 Link to comment Share on other sites More sharing options...
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