Sign in to follow this  
Followers 0
Bernd Braun

Check Process

7 posts in this topic

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") Then

Run("c:\novell\clientlocalinstall\poweroff.exe reboot -force -quiet")

Else

Run(@SystemDir & "\shutdown -f -r -t 00")

EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 :

$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 to avoid a hung script.

5 minutes is $allowed = 300000 to set it for as requested :think:

Edited by MHz

Share this post


Link to post
Share on other sites

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 :

$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 !!

Share this post


Link to post
Share on other sites

Fast, well thanks. CyberSlugs response was a good one also to take note of.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0