Lcreager Posted July 16, 2013 Share Posted July 16, 2013 I am having a problem getting the data (printer names) from my array to show up in the RunWait command. The data is read from an .ini file and used to create check-boxes. In a later function (_PrinterInstall) it should be read again and used in the RunWait command to install the network printer. When the command runs, the place where the printer name would be is blank. expandcollapse popup#include <GUIConstantsEx.au3> Opt("GuiOnEventMode",1) Global $CompanyName = IniRead("settings.ini","CompanyName","name","") Global $GUIheight = IniRead("settings.ini","WindowSize","height","400") Global $GUIwidth = IniRead("settings.ini","WindowSize","width","500") Global $printserver = IniRead("settings.ini","ServerSettings", "PrintServer", "Not Found") Global $Printers = IniRead("settings.ini","Printers","PrinterList","NotFound") Global $printarr = StringSplit ($Printers, ",") Global $iPrinternumber = UBound($printarr) - 1 Global $box[$printarr[0] + 1] Global $hService Global $iTop = 0, $iLeft =(.1 * $GUIwidth) GUICreate($CompanyName & " Printer Installer", $GUIwidth, $GUIheight) ;GUISetBkColor(0x33ccff) GUISetOnEvent($GUI_EVENT_CLOSE, "_CLOSEClicked") $Title = GUICtrlCreateLabel("Select the Printers to be Installed", (.3 * $GUIwidth), 15, 300) GUICtrlSetFont($Title, 11,400,2) For $i = 1 To $iPrinternumber If $iTop >= ($GUIheight - 100) Then $iLeft = (.6 * $GUIwidth) $iTop = 0 Else EndIf $box[$i]= GUICtrlCreateCheckbox($printarr[$i], $iLeft, $iTop + 40) $iTop = $iTop + 20 Next $InstallButton = GUICtrlCreateButton("Install Selected", .1 * $GUIwidth, $GUIheight - 50, 150) $ExitButton = GUICtrlCreateButton("Exit", .6 * $GUIwidth, $GUIheight -50, 150) GUIctrlSetOnEvent($InstallButton, "_PrinterInstall") GUICtrlSetOnEvent($ExitButton, "_CLOSEClicked") GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd Func _CLOSEClicked () Exit EndFunc Func _PrinterInstall () SplashTextOn("", "Installing printer, please wait...", 150, 75) For $i = 1 To $iPrinternumber If GUICtrlRead($box[$i]) = $GUI_CHECKED Then RunWait(@SystemDir & "\RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /q /u /n\\" & $printserver & "\" & $printarr[$i]) GUICtrlSetState($box[$i], $GUI_UNCHECKED) Else EndIf next SplashOff() MsgBox(0,"Done","Printer instlation complete") EndFunc The contents of the .ini file I am using [Printers] PrinterList = PRT_BC_Counter_53, PRT_GL_Counter_49, PRT_GR_AcctsPayable_30, PRT_GR_APCheck, PRT_GR_Credit_31, PRT_GR_Exec_40, PRT_GR_Fireplaces, PRT_GR_HVACBuyers_62, PRT_GR_KitchensColor_61, PRT_GR_KitchensHP_54, PRT_GR_Outlet, PRT_GR_PartsCounter_24, PRT_GR_Ship_4, PRT_GR_ShippingOffice_39, PRT_GR_VaultColor_25, PRT_HL_Counter_50, PRT_HW_Counter_81, PRT_HW_Motors_64, PRT_HW_Shipping_63, PRT_KW_BackOffice_37, PRT_KW_Color_36, PRT_KZ_Counter_57, PRT_LN_COUNTER_79, PRT_Ls_Counter_56, PRT_MC_Counter_51, PRT_MU_Counter_87, PRT_MW_Counter_12, PRT_PL_Counter_59, PRT_PT_Counter_82, PRT_PT_HPG, PRT_SB_Counter_86, PRT_SF_Counter_83, PRT_TR_Counter_85, PRT_TY_Counter_84 [serverSettings] PrintServer = ad1 [WindowSize] height = 400 width = 500 [CompanyName] name = WMSDIST Link to comment Share on other sites More sharing options...
BrewManNH Posted July 16, 2013 Share Posted July 16, 2013 This is what I get in your RunWait command line. C:Windowssystem32RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /q /u /nad1 PRT_PT_HPG Isn't that what you're getting? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Lcreager Posted July 16, 2013 Author Share Posted July 16, 2013 This is what I get in your RunWait command line. Isn't that what you're getting? Nope, I get the following box. Link to comment Share on other sites More sharing options...
BrewManNH Posted July 16, 2013 Share Posted July 16, 2013 Where is your ini file when you're running the script? What do you get inside $printarr after reading it? Have you done any troubleshooting of the script to figure out where it's going wrong? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Lcreager Posted July 16, 2013 Author Share Posted July 16, 2013 The .ini file is in the same directory the script is being run from. I do get the correct printer name in $printarr, I used this code to check it before and after the RunWait command, MsgBox(0,"test",$printarr[$i]). However it does not seem to work IN the RunWait command and I am unsure why. Link to comment Share on other sites More sharing options...
BrewManNH Posted July 16, 2013 Share Posted July 16, 2013 It's working fine for me as written, so I can't see why it wouldn't work for you as well. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Lcreager Posted July 16, 2013 Author Share Posted July 16, 2013 Well it is good to know I did not make any programming mistakes. I guess I will have to continue to troubleshoot and see if I can find the issue. Thanks for the second look and your time. 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