Bernd Braun Posted April 7, 2006 Posted April 7, 2006 Can I check how long a process is running ?I make the installation of the Novell Client and ZenWorks. Sometimes the process setupnw.exe is coming into a loop - if this happens the process and the autoit process have to be killed:BlockInput(1)RegDelete("HKEY_LOCAL_MACHINE\software\novell")RegDelete("HKEY_LOCAL_MACHINE\Software\ndps")runwait("C:\novell\ClientLocalInstall\acu.exe /u /sl /d:no")Here should be checked if the process setupnw.exe is running longer than 5 minutes !RunWait("c:\windows\system32\msiexec.exe /i C:\novell\ClientLocalInstall\ZfDAgent.msi /qn REBOOT=REALLYSUPPRESS ADDLOCAL=WorkstationManager,ApplicationLauncher,RemoteManagement STARTUP_APPEXPLORER=1")$Workstationname = RegRead("HKEY_LOCAL_MACHINE\software\gb", "Workstation Object")$Workstationid = RegRead("HKEY_LOCAL_MACHINE\software\gb", "Workstation ID")RegWrite("HKEY_LOCAL_MACHINE\software\novell\workstation manager\identification", "Workstation Object", "REG_SZ", $Workstationname)RegWrite("HKEY_LOCAL_MACHINE\software\novell\workstation manager\identification", "REG_SZ", $Workstationid)FileDelete(@SystemDir & "\drishti*.dll")RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon")RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoLogonCount")RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword")RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", "")RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "compatiblerupsecurity" , "REG_DWORD", "00000001")RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Novell Client for Windows NT")if FileExists("c:\novell\clientlocalinstall\poweroff.exe") ThenRun("c:\novell\clientlocalinstall\poweroff.exe reboot -force -quiet")ElseRun(@SystemDir & "\shutdown -f -r -t 00")EndIf
CyberSlug Posted April 7, 2006 Posted April 7, 2006 (edited) Replace runwait("C:\novell\ClientLocalInstall\acu.exe /u /sl /d:no") with the following: run("C:\novell\ClientLocalInstall\acu.exe /u /sl /d:no") $timer = TimerInit() While ProcessExists("setupnw.exe") sleep(1000) If TimerDiff($timer) > 5*60*1000 Then MsgBox(0x1000,"Info","Modify code here to Taskkill the hung process...") EndIf Wend Edit: Had 10 instead of 60. 5*60*1000 should be the number of milliseconds in 5 minutes, I think. Edited April 7, 2006 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
MHz Posted April 7, 2006 Posted April 7, 2006 Try this sample $time = TimerInit() $allowed = 5000 AdlibEnable('_timeout') While 1 Sleep(1000) WEnd Func _timeout() If TimerDiff($time) > $allowed Then Exit 1 EndFunc AdlibEnable will kill the script as shown.
Bernd Braun Posted April 7, 2006 Author Posted April 7, 2006 Try this sample $time = TimerInit() $allowed = 5000 AdlibEnable('_timeout') While 1 Sleep(1000) WEnd Func _timeout() If TimerDiff($time) > $allowed Then Exit 1 EndFunc AdlibEnable will kill the script as shown. Where in the skript must this function putted in ? - At the beginning ?
MHz Posted April 7, 2006 Posted April 7, 2006 (edited) The 1st 3 ines can be added at the start of your script and the function can be added preferably out of the way at the bottom of your script so :expandcollapse popup$time = TimerInit() $allowed = 5000 AdlibEnable('_timeout') BlockInput(1) RegDelete("HKEY_LOCAL_MACHINE\software\novell") RegDelete("HKEY_LOCAL_MACHINE\Software\ndps") runwait("C:\novell\ClientLocalInstall\acu.exe /u /sl /d:no") Here should be checked if the process setupnw.exe is running longer than 5 minutes ! RunWait("c:\windows\system32\msiexec.exe /i C:\novell\ClientLocalInstall\ZfDAgent.msi /qn REBOOT=REALLYSUPPRESS ADDLOCAL=WorkstationManager,ApplicationLauncher,RemoteManagement STARTUP_APPEXPLORER=1") $Workstationname = RegRead("HKEY_LOCAL_MACHINE\software\gb", "Workstation Object") $Workstationid = RegRead("HKEY_LOCAL_MACHINE\software\gb", "Workstation ID") RegWrite("HKEY_LOCAL_MACHINE\software\novell\workstation manager\identification", "Workstation Object", "REG_SZ", $Workstationname) RegWrite("HKEY_LOCAL_MACHINE\software\novell\workstation manager\identification", "REG_SZ", $Workstationid) FileDelete(@SystemDir & "\drishti*.dll") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoLogonCount") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", "") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "compatiblerupsecurity" , "REG_DWORD", "00000001") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Novell Client for Windows NT") if FileExists("c:\novell\clientlocalinstall\poweroff.exe") Then Run("c:\novell\clientlocalinstall\poweroff.exe reboot -force -quiet") Else Run(@SystemDir & "\shutdown -f -r -t 00") EndIf Func _timeout() If TimerDiff($time) > $allowed Then Exit 1 EndFuncSet $allowed to the time which you want the script to execute for if to avoid a hung script.5 minutes is $allowed = 300000 to set it for as requested Edited April 7, 2006 by MHz
Bernd Braun Posted April 7, 2006 Author Posted April 7, 2006 The 1st 3 ines can be added at the start of your script and the function can be added preferably out of the way at the bottom of your script so : expandcollapse popup$time = TimerInit() $allowed = 5000 AdlibEnable('_timeout') BlockInput(1) RegDelete("HKEY_LOCAL_MACHINE\software\novell") RegDelete("HKEY_LOCAL_MACHINE\Software\ndps") runwait("C:\novell\ClientLocalInstall\acu.exe /u /sl /d:no") Here should be checked if the process setupnw.exe is running longer than 5 minutes ! RunWait("c:\windows\system32\msiexec.exe /i C:\novell\ClientLocalInstall\ZfDAgent.msi /qn REBOOT=REALLYSUPPRESS ADDLOCAL=WorkstationManager,ApplicationLauncher,RemoteManagement STARTUP_APPEXPLORER=1") $Workstationname = RegRead("HKEY_LOCAL_MACHINE\software\gb", "Workstation Object") $Workstationid = RegRead("HKEY_LOCAL_MACHINE\software\gb", "Workstation ID") RegWrite("HKEY_LOCAL_MACHINE\software\novell\workstation manager\identification", "Workstation Object", "REG_SZ", $Workstationname) RegWrite("HKEY_LOCAL_MACHINE\software\novell\workstation manager\identification", "REG_SZ", $Workstationid) FileDelete(@SystemDir & "\drishti*.dll") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoLogonCount") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", "") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "compatiblerupsecurity" , "REG_DWORD", "00000001") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Novell Client for Windows NT") if FileExists("c:\novell\clientlocalinstall\poweroff.exe") Then Run("c:\novell\clientlocalinstall\poweroff.exe reboot -force -quiet") Else Run(@SystemDir & "\shutdown -f -r -t 00") EndIf Func _timeout() If TimerDiff($time) > $allowed Then Exit 1 EndFunc Set $allowed to the time which you want the script to execute for if it hangs. Cool- many thanks for the fast help !!
MHz Posted April 7, 2006 Posted April 7, 2006 Fast, well thanks. CyberSlugs response was a good one also to take note of.
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