Lattis2003 Posted August 4, 2007 Share Posted August 4, 2007 New to Autoit. Trying to move away from vbscript. Need to pass the variable $strComputer at the end of the printmig.exe to restore printers. Not getting any syntax errors and i have tried different syntax's at the end for strComputer Thanks printmig.exe switches usage: PRINTMIG [options] [server] [-?] Display this message [-b] Backup - followed by CAB file name [-r] Restore - followed by CAB file name [-l] Attempt to convert LPR Ports to SPM [-i] Suppress warning popups. Info still written to log file If server is not specified then the local machine is implied. Example command line to restore an existing config to a server: printmig -r d:\print\ps1.cab \\prt-srvr1 Example command line to backup a server to the specified file: printmig -b "\\filesrv\store\print server 2.cab" \\prt-srvr2 CODE ;This works Func Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab \\remotecomputername") MsgBox(0, "Verify input strComputer", GUICtrlRead($strComputer)) EndFunc ;This does not work Func Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputer ") MsgBox(0, "Verify input strComputer", GUICtrlRead($strComputer)) EndFunc Link to comment Share on other sites More sharing options...
SadBunny Posted August 4, 2007 Share Posted August 4, 2007 ;This does not workFunc Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputer ") MsgBox(0, "Verify input strComputer", GUICtrlRead($strComputer))EndFuncIn your msgbox you use GUICtrlRead($strComputer) and in your runwait you use $strComputer. Try using GUICtrlRead($strComputer) in the runwait command too Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 4, 2007 Share Posted August 4, 2007 CODE ;This works Func Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab \\remotecomputername") MsgBox(0, "Verify input strComputer", GUICtrlRead($strComputer)) EndFunc ;This does not work Func Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputer ") MsgBox(0, "Verify input strComputer", GUICtrlRead($strComputer)) EndFunc The only problem I see is the stray double quotes on the very end of the RunWait() string, after $strComputer. Func Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputer ") ; This shouldn't be here ------------------------------------------------------^ MsgBox(0, "Verify input strComputer", GUICtrlRead($strComputer)) EndFunc Running that code in SciTE should have given you errors in the console that would have pointed it out. 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 Link to comment Share on other sites More sharing options...
Lattis2003 Posted August 4, 2007 Author Share Posted August 4, 2007 The only problem I see is the stray double quotes on the very end of the RunWait() string, after $strComputer. Func Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputer ") ; This shouldn't be here ------------------------------------------------------^ MsgBox(0, "Verify input strComputer", GUICtrlRead($strComputer)) EndFunc Running that code in SciTE should have given you errors in the console that would have pointed it out. PsaltyDS I did remove the stray double quote after $strComputer and get no error in SciTE. I pasted the wrong code due to trying to many strings. The problem is i never can get the varaible to pass to the command printmig.exe. I have set the variable $strComputerName = GUICtrlRead($strComputer) in my loop. The msg box echo's the correct info. CODE Func Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputerName) MsgBox(0, "Variable for The Computer Name", $strComputerName) EndFunc I have also set $strComputerName = "\\" & GUICtrlRead($strComputer) This echo's the correct string. CODE Func Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab" & $strComputerName) MsgBox(0, "Variable for The Computer Name", $strComputerName) EndFunc either should run the exe as printmig.exe -r e:\printers\printers.cab \\remotecomputer I am at a loss. Thanks Link to comment Share on other sites More sharing options...
Lattis2003 Posted August 5, 2007 Author Share Posted August 5, 2007 PsaltyDSI did remove the stray double quote after $strComputer and get no error in SciTE. I pasted the wrong code due to trying to manystrings. The problem is i never can get the varaible to pass to the command printmig.exe. I have set the variable$strComputerName = GUICtrlRead($strComputer) in my loop. The msg box echo's the correct info.CODEFunc Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputerName) MsgBox(0, "Variable for The Computer Name", $strComputerName)EndFunc I have also set $strComputerName = "\\" & GUICtrlRead($strComputer)This echo's the correct string.CODEFunc Printer1() RunWait("printmig.exe -r E:\Printers\Printers.cab" & $strComputerName) MsgBox(0, "Variable for The Computer Name", $strComputerName)EndFunc either should run the exe as printmig.exe -r e:\printers\printers.cab \\remotecomputerI am at a loss.ThanksSolved.I was failing to put a space in for the " \\"RunWait("printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputerName)RunWait("printmig.exe -r E:\Printers\Printers.cab" & " \\" & $strComputerName)Thanks everyone. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 5, 2007 Share Posted August 5, 2007 Solved. I was failing to put a space in for the " \\" RunWait("printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputerName) RunWait("printmig.exe -r E:\Printers\Printers.cab" & " \\" & $strComputerName) Thanks everyone. Good catch. I got in the habit, as a first troubleshooting step when assembled strings like that don't work, to assemble them before running. It adds a line to the script but makes debugging much easier: $sExtCmd = "printmig.exe -r E:\Printers\Printers.cab" & "\\" & $strComputerName ConsoleWrite("Debug: $sExtCmd = " & $sExtCmd & @LF) RunWait($sExtCmd) It becomes especially hard to debug that kind of string when there is a mix of single-quotes and double-quotes mixed in, and that ConsoleWrite() makes the mistakes stand out. The script would be coded without the ConsoleWrite's, but the Run's would be in two lines as shown. If I had to debug a line, I would just put the ConsoleWrite in to see how it actually came out. 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 Link to comment Share on other sites More sharing options...
Lattis2003 Posted August 5, 2007 Author Share Posted August 5, 2007 Thanks PsaltyDS I went the long way around finding my mistake. I made a vbscript with some input boxes to test my output and when i entered " \\" i automatically hit the space bar to add the correct space and bam it hit me. I felt like an idiot. Thanks for the debug tip as this will come in very handy for me. It's just going to take me a few weeks to get in the groove again as i have been away from scripting a couple years. I decided to try AutoIt since it gives so much more to work with. Plus it makes it more fun to start again. Thanks Again for your help. 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