gte Posted May 18, 2009 Share Posted May 18, 2009 I apologize that the entire code isn't here, but I think it would fail if it was ran on a machine outside of our domain? Does anyone see any obvious errors with this? Everything works, EXCEPT for " If $dateparse2[$i] < 10 Then $dateparse2[$i] = '0' & $dateparse2[$i] " . I need the 0's added in for numbers less than 10, for a batch file that creates a scheduled task, and it's not parsing the 0 place holders in? Any help would be great, thanks! expandcollapse popupif guictrlread($check_notificationlaterdate) = $gui_checked Then ; $drop_calendarnotif = $timestring2 & ':' & $drop_minutesnotif & ':' & $drop_secondsnotif MsgBox(0,'test', '1') ; $notiflaterdatetask = guictrlread($drop_calendarnotif) $schtasksnotiflaterdate = guictrlread($drop_calendarnotif) MsgBox(0,'schtaskslaterdatevalue', $schtasksnotiflaterdate) $dateparse2 = stringsplit($schtasksnotiflaterdate, '/') MsgBox(0, 'dateparse2', $dateparse2) For $i = 1 to $dateparse2[0] Step 1 MsgBox(0,'dateparse2', $dateparse2) If $dateparse2[$i] < 10 Then $dateparse2[$i] = '0' & $dateparse2[$i] MsgBox(0,'dateparse2', $dateparse2) Next MsgBox(0,'test', '5') For $f = 1 to $dateparse2[0] Step 1 ; $notiflaterdatetask = $dateparse2[1] & '/' & $dateparse2[2] & '/' & $dateparse2[3] MsgBox(0, 'dateparse2', $dateparse2[$f]) Next MsgBox(0, 'schtaskslaterdatevalue2', $schtasksnotiflaterdate) ;~ Next MsgBox(0,'test', '6') MsgBox(0,'timestring (hours)', $timestring) MsgBox(0,'minutes', GUICtrlRead($minutesdropdownboxinput)) MsgBox(0,'seconds', GUICtrlRead($secondsdropdownboxinput)) MsgBox(0,'sch task date', $schtaskstartdate) $schtaskamorpm = guictrlread($schtaskampmmenu) MsgBox(0, 'update', 'checking whether am or pm was selected') if $schtaskamorpm = 'AM' Then $schtaskampmoutput = '+0' MsgBox(4096, "Test", " You selected AM ", 3) ElseIf $schtaskamorpm = "PM" Then $schtaskampmoutput = '+12' MsgBox(4096, "Test", " You selected PM ", 3) Elseif $schtaskamorpm = 'AM or PM?' Then MsgBox(4096, 'Error', 'Please select either AM or PM') EndIf MsgBox(0, 'update', 'done checking if am or pm was selected') EndIf HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 18, 2009 Share Posted May 18, 2009 I apologize that the entire code isn't here, but I think it would fail if it was ran on a machine outside of our domain? Does anyone see any obvious errors with this? Everything works, EXCEPT for " If $dateparse2[$i] < 10 Then $dateparse2[$i] = '0' & $dateparse2[$i] " . I need the 0's added in for numbers less than 10, for a batch file that creates a scheduled task, and it's not parsing the 0 place holders in? Any help would be great, thanks! Just use StringFormat(): Global $dateparse2[3] = ["100", "20", 3] For $i = 0 to UBound($dateparse2) - 1 ConsoleWrite($dateparse2[$i] & " = " & StringFormat("%03u", $dateparse2[$i]) & @LF) Next 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...
foster74 Posted May 18, 2009 Share Posted May 18, 2009 Are you going just off the msgbox? Because if so you should have: For $i = 1 to $dateparse2[0] Step 1 MsgBox(0,'dateparse2', $dateparse2[$i]) If $dateparse2[$i] < 10 Then $dateparse2[$i] = '0' & $dateparse2[$i] MsgBox(0,'dateparse2', $dateparse2[$i]) Next Link to comment Share on other sites More sharing options...
gte Posted May 19, 2009 Author Share Posted May 19, 2009 Foster, I have a schtask output msg box that I am going by, and the value for $schtasksnotiflaterdate is still not 8 digits like it should be and I'm not sure what I have wrong, as I have this same script working correctly somewhere else in the exe? Are you going just off the msgbox? Because if so you should have: For $i = 1 to $dateparse2[0] Step 1 MsgBox(0,'dateparse2', $dateparse2[$i]) If $dateparse2[$i] < 10 Then $dateparse2[$i] = '0' & $dateparse2[$i] MsgBox(0,'dateparse2', $dateparse2[$i]) Next HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
gte Posted May 19, 2009 Author Share Posted May 19, 2009 Psalty, I tried what you suggested (I think) and the result was the same expandcollapse popupif guictrlread($check_notificationlaterdate) = $gui_checked Then ; $drop_calendarnotif = $timestring2 & ':' & $drop_minutesnotif & ':' & $drop_secondsnotif MsgBox(0,'test', '1') ; $notiflaterdatetask = guictrlread($drop_calendarnotif) $schtasksnotiflaterdate = guictrlread($drop_calendarnotif) MsgBox(0,'schtaskslaterdatevalue', $schtasksnotiflaterdate) $dateparse2 = stringsplit($schtasksnotiflaterdate, '/') MsgBox(0, 'dateparse2', $dateparse2) Global $dateparse2[3] = ["100", "20", 3] For $i = 0 to UBound($dateparse2) - 1 ConsoleWrite($dateparse2[$i] & " = " & StringFormat("%03u", $dateparse2[$i]) & @LF) Next ;~ For $i = 1 to $dateparse2[0] Step 1 ;~ MsgBox(0,'dateparse2', $dateparse2[$i]) ;~ If $dateparse2[$i] < 10 Then $dateparse2[$i] = '0' & $dateparse2[$i] ;~ MsgBox(0,'dateparse2', $dateparse2[$i]) ;~ Next MsgBox(0,'test', '5') For $f = 1 to $dateparse2[0] Step 1 ; $notiflaterdatetask = $dateparse2[1] & '/' & $dateparse2[2] & '/' & $dateparse2[3] MsgBox(0, 'dateparse2', $dateparse2[$f]) Next MsgBox(0, 'schtaskslaterdatevalue2', $schtasksnotiflaterdate) ;~ Next MsgBox(0,'test', '6') msgbox(0, 'dateparse final', $dateparse2) MsgBox(0,'timestring (hours)', $timestring) MsgBox(0,'minutes', GUICtrlRead($minutesdropdownboxinput)) MsgBox(0,'seconds', GUICtrlRead($secondsdropdownboxinput)) MsgBox(0,'sch task date', $schtaskstartdate) $schtaskamorpm = guictrlread($schtaskampmmenu) MsgBox(0, 'update', 'checking whether am or pm was selected') if $schtaskamorpm = 'AM' Then $schtaskampmoutput = '+0' MsgBox(4096, "Test", " You selected AM ", 3) ElseIf $schtaskamorpm = "PM" Then $schtaskampmoutput = '+12' MsgBox(4096, "Test", " You selected PM ", 3) Elseif $schtaskamorpm = 'AM or PM?' Then MsgBox(4096, 'Error', 'Please select either AM or PM') EndIf MsgBox(0, 'update', 'done checking if am or pm was selected') EndIf msgbox(0,'test','start runwait task now') $schtaskvalue = RunWait('schtasks.exe /create /s ' & $server & ' /u ' & $schtaskusername & ' /p ' & $schtaskpassword & ' /ru ' & $schtaskusername & ' /rp ' & $schtaskpassword & ' /sc once /tn ' & $schtaskname & ' /tr ' & $schtaskrunfile & ' /st ' & $timestring & ':' & guictrlread($minutesdropdownboxinput) & ':' & guictrlread($secondsdropdownboxinput) & ' /sd ' & $schtaskstartdate, @WindowsDir) MsgBox(0, "Run Command Output", 'schtasks.exe /create /s ' & $server & ' /u ' & $schtaskusername & ' /p ' & $schtaskpassword & ' /ru ' & $schtaskusername & ' /rp ' & $schtaskpassword & ' /sc once /tn ' & $schtaskname & ' /tr ' & $schtaskrunfile & ' /st ' & $timestring & ':' & guictrlread($minutesdropdownboxinput) & ':' & guictrlread($secondsdropdownboxinput) & ' /sd ' & $schtaskstartdate, @WindowsDir) MsgBox(0,'test', 'calling _makefile() function') _makefile() MsgBox(0, 'test', 'task created') if guictrlread($check_notificationlaterdate) = $gui_checked Then $schtaskvalue2 = RunWait('schtasks.exe /create /s ' & $server & ' /u ' & $schtaskusername & ' /p ' & $schtaskpassword & ' /ru ' & $schtaskusername & ' /rp ' & $schtaskpassword & ' /sc once /tn ' & $schtaskname2 & ' /tr ' & $schtaskrunfile2 & ' /st ' & $timestring2 & ':' & guictrlread($drop_minutesnotif) & ':' & guictrlread($drop_secondsnotif) & ' /sd ' & $schtasksnotiflaterdate, @WindowsDir) MsgBox(0, "Run Command Output for notification task", 'schtasks.exe /create /s ' & $server & ' /u ' & $schtaskusername & ' /p ' & $schtaskpassword & ' /ru ' & $schtaskusername & ' /rp ' & $schtaskpassword & ' /sc once /tn ' & $schtaskname2 & ' /tr ' & $schtaskrunfile2 & ' /st ' & $timestring2 & ':' & guictrlread($drop_minutesnotif) & ':' & guictrlread($drop_secondsnotif) & ' /sd ' & $schtasksnotiflaterdate, @WindowsDir) MsgBox(0,'test', 'calling _makenotification seperate event() function') _makenotificationseperateevent() MsgBox(0, 'test', 'finished calling makenotificationseperateevent function') EndIf Just use StringFormat(): Global $dateparse2[3] = ["100", "20", 3] For $i = 0 to UBound($dateparse2) - 1 ConsoleWrite($dateparse2[$i] & " = " & StringFormat("%03u", $dateparse2[$i]) & @LF) Next HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 19, 2009 Share Posted May 19, 2009 Psalty, I tried what you suggested (I think) and the result was the same MsgBox(0,'schtaskslaterdatevalue', $schtasksnotiflaterdate) $dateparse2 = stringsplit($schtasksnotiflaterdate, '/') MsgBox(0, 'dateparse2', $dateparse2) Global $dateparse2[3] = ["100", "20", 3] For $i = 0 to UBound($dateparse2) - 1 ConsoleWrite($dateparse2[$i] & " = " & StringFormat("%03u", $dateparse2[$i]) & @LF) Too much the same. What I posted was a stand-alone demo, not meant to be plugged directly into your code. Run just the demo I posted, and look up StringFormat() in the help file to see how it works. Then you'll be able to use it in this script, or any other. 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...
gte Posted May 19, 2009 Author Share Posted May 19, 2009 I got it working, thanks!Too much the same. What I posted was a stand-alone demo, not meant to be plugged directly into your code. Run just the demo I posted, and look up StringFormat() in the help file to see how it works. Then you'll be able to use it in this script, or any other. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script 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