Jump to content

How to suspend a process for some time


ur
 Share

Recommended Posts

with the below code, I am keeping waiting for a particular file and waiting in the background.

While $i <> 10
 Sleep(60000)
    If FileExists(@ScriptDir&"\Binaries.ini") then
        --some processing--
        $i = 10
    endif
WEnd

I thought keeping the Sleep will freeze the process from resources but the CPU being uilized.But it is taking 47%.

How to free this CPU usage also.?

123.PNG

Link to comment
Share on other sites

There must be more to that script, to cause that cpu usage. The code you have  there shouldn't use that much cpu.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

1 hour ago, careca said:

There must be more to that script, to cause that cpu usage. The code you have  there shouldn't use that much cpu.

But it should release the resources atleast during the Sleep time right.
But it isn't.

Link to comment
Share on other sites

51 minutes ago, ur said:

But it should release the resources

resources, now ur talking RAM usage. Cpu is all about processing stuff. is there any adlib funcs for instance?

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

THis is my script.

 

Local $i = 0
While $i <> 10
    Sleep(60000);1min
    If FileExists(@ScriptDir&"\Binaries.ini") then
        
        WaitForINICompletion(@ScriptDir&"\Binaries.ini")
        SendMail("Binaries copied to Installshield machine","Got Binaries.ini: Will initmate once Install creation started")
         Sleep(5000)
        
        ;MsgBox($MB_SYSTEMMODAL, "", "Value of $i is: " & $i)
        ChangeWin32(@ScriptDir&"\Binaries.ini")
        CheckZip(@ScriptDir&"\Binaries.ini")
        AppendBinaries(@ScriptDir&"\Binaries.ini",@ScriptDir&"\BinaryDetails.ini")
        if(FileExists(@ScriptDir&"\copy.exe")) then
            Local $iReturn = Runwait(@ScriptDir&"\copy.exe", "", @SW_MAXIMIZE)
            if not @error Then
                ;Logging("execution completed successfully with Return Code: " & $iReturn,4)
            Else
                ;Logging("execution failed with Return Code: " & $iReturn,4)
            EndIf
            ;FileMove(@ScriptDir&"\BinaryDetails.ini", @ScriptDir&"\BinaryDetails_old.ini", 0)
            ;MsgBox($MB_SYSTEMMODAL, "", "The return code from CreateSetup was: " & $iReturn)
        EndIf
        if(FileExists(@ScriptDir&"\CreateSetup.exe")) then
            Local $iReturn = Runwait(@ScriptDir&"\CreateSetup.exe", "", @SW_MAXIMIZE)
            if not @error Then
                ;Logging("execution completed successfully with Return Code: " & $iReturn,4)
            Else
                ;Logging("execution failed with Return Code: " & $iReturn,4)
            EndIf
            ;FileMove(@ScriptDir&"\BinaryDetails.ini", @ScriptDir&"\BinaryDetails_old.ini", 0)
            ;MsgBox($MB_SYSTEMMODAL, "", "The return code from CreateSetup was: " & $iReturn)
        EndIf
    EndIf

WEnd
Func Logging($sMessage,$sLogFile=@ScriptDir&"\Logging.log")
    If $sMessage = "" Then
        FileWriteLine($sLogFile, "")
    Else
        FileWrite($sLogFile,_NowCalc() & " :: " & $sMessage&@CRLF)
    EndIf
EndFunc

 

Link to comment
Share on other sites

  • Moderators

@ur as usual it is like pulling teeth with you. How are we supposed to help you narrow down the problem when you have, by my count, 5 custom functions (WaitForINICompletion, SendMail, ChangeWin32, CheckZip, AppendBinaries) in there that you are not sharing with us?

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

copy and createsetup exe's running in background?

I was late, but what do you mean before entering the if blocks?

a sleep inside a loop doesnt use cpu at all.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

No, I kept wait for the Binaries.ini file in the background.

Only when the file appears or copied from another machine in the network to this folder, then the createsetup and copy exe file will run.

But the CPU is 97% when it is still waiting

Link to comment
Share on other sites

that's probably not the whole script either. i'm done. have fun. i would look at it using ProcessViewer and see what resources it is using. That will probably answer your question.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

Sorry @Earthshine, these are the main scripts.

Are you getting any error during compilation?

If it is for .ps1 files, just keep some dummy files, I don't have them also, they need for other fumctions in the library.au3 which we are not using here.

Edited by ur
Link to comment
Share on other sites

ProcessExplorer from SysInternals is your friend. click on your running process that you think is sleeping and look at the dlls and other resources it uses.

I do not believe that sleeping should release allocated resources.

https://live.sysinternals.com/procexp64.exe

https://live.sysinternals.com/procexp.exe

you could also use ProcMon to see what's getting hit, registry, file system, etc..

https://live.sysinternals.com/Procmon.exe

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

Yea, this is not going anywhere.

Comment functions one by one until you see a reduction in cpu usage, then you can focus on that specific function to see what's up.

Good luck

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • Developers
1 hour ago, ur said:

Sorry @JLogan3o13

These are the au3 files.And the dependent library.au3

Createsetup.exe and copy.exe are tirdparty ones and we don't have source code with us.

But anyway, the issue is before entering the if blocks.
 

BackroundforBinaries.au3

Library.au3

Unlike the others shooting from the hip at your lack of info provided: What did your debugging reveal?
You can't come in here posting constantly these questions without having done some basic debugging yourself. (I am pretty sure I am repeating myself to you now!)

You should know how to do this debugging by now, so start thinking for a change and doing the work yourself! Come back when you have more to show for.

Jos

 

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

2 hours ago, Jos said:

...shooting from the hip

 

 

nice analogy ;)

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Yeah.  Never post results from the console even. My current hypothesis is that us, he isn’t sleeping it’s doing something and he’s not aware of it because there’s no logging and he doesn’t know what the he k is going on 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

  • Developers

You are just guessing while it is VERY simple to debug with the options available  and a little effort.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...