Re: System sleep

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Michael Harris \(MVP\) ("Michael)
Date: 11/14/04


Date: Sun, 14 Nov 2004 13:40:17 -0800

Pippen wrote:
> Here is a code snippet that works but I'm looking for something that
> is not so CPU intensive to perform a sleep. The problem is that I
> have to decrypt a PGP program using the CmdShell. Once the file is
> decrypted I want to move the encrypted file to another directory.
> What I have done is create my own little timer delay that hit's the
> CPU harder than it should. Is there a way to use a sleep function
> that will wait without hitting the CPU. The reason I need the sleep
> funtion is that the VBScript does not wait for the CmdShell program
> to finish and moves the file before PGP can decrypt it... Note the
> variables and objects are created in other parts of the code; this is
> an incomplete snippet of code.
>
> VBScript is not my primary language, I use VBScript exclusively in DTS
> packages on MS SQL 2000 as an ActiveX step. Does anybody know a good
> book or site that deals with this aspect of VBScript. Every book or
> resource I have seen deals primarily with web pages.

I'd suggest you simply use

    objShell.Run strCmdDecryptFiles,0,true 'hidden window, wait for
completion...

rather than

    Set objScriptExec = objShell.Exec(strCmdDecryptFiles)

especially since you do not appear to make use of the features of the
objScriptExec object. I would do this even in a WSH hosted script where
WScript.Sleep is available (which is not available in your SQL/DTS
environment).

>
> Thanks,
>
> -p
>
>
> If objFSO.FileExists(strFileNameBko) Then
> 'Decrypt the file and remove the .pgp from the end
> strBKOoutput = Mid(strFileNameBko,1,Len(strFileNameBko) - 4)
> strCmdDecryptFiles = strGPGPathFile + " --output " + strBKOoutput
> + --decrypt " + strFileNameBko
> Set objScriptExec = objShell.Exec(strCmdDecryptFiles)
>
> -- BEGIN OFFENDING CODE
> ' have to slow it down moving the file before being decrypted
> TimeBKO = Now
> While DiffBKOTime < intSleepSeconds
> if objFSO.FileExists(strBKOoutput) Then
> DiffBKOTime = DateDiff("S", TimeBKO, Now)
> End If
> WEnd
> -- END OFFENDING CODE
>
> 'Move Encrypted file to DTS Global defined directory
> set FileToMove = objFSO.GetFile(strFileNameBko)
> FileToMove.Move(strEncryptedReturnFilesPath)
>
> End If

-- 
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US


Relevant Pages

  • Re: Re-entrancy???
    ... Sleep calls will just slow the application down. ... Whether or not PeekMessage is occuring in DoEvents ... has no impact on the overall CPU utilization. ... correctly, using the timeXXXX-APIs. ...
    (microsoft.public.vb.general.discussion)
  • Re: cpufreq est and Enhanced Sleep (Cx) States for Intel Core and above
    ... Adam McDougall wrote: ... >> Another thing I wish could work is the Enhanced cpu Sleep States; ... The major reason being that the acpi cpu> driver does not support well multiprocessor systems. ... I've not updated the patch since then so> it might or might not apply cleanly to a recent current. ...
    (freebsd-current)
  • Re: cpufreq est and Enhanced Sleep (Cx) States for Intel Core and above
    ... > Another thing I wish could work is the Enhanced cpu Sleep States; ... > this Dell Latitude D820 laptop only sees C1 although the document ... > acpi stuff and/or verbose boot logs if it would be helpful. ...
    (freebsd-current)
  • Re: DoEvents and Sleep
    ... the Sleep API to release the remaining time slice ... to avoid using a lot of CPU time. ... Consuming a lot of CPU is a problem for laptops, as power consumption is ... Isn't the app requiring the same number of clock cycles, ...
    (microsoft.public.vb.general.discussion)
  • Re: Print Spooling vs suspend
    ... dropped to sleep. ... The print job was deleted and the computer ... Do you mean Stand By mode (or Hibernate)? ... That check uses the CPU, the network if printers are on the network, and other port drivers if ...
    (microsoft.public.windowsxp.general)