Sign in to follow this  
Followers 0
RvdH

Autoit Program (unresponsive)

11 posts in this topic

#1 ·  Posted (edited)

I've wrapped up a couple of scripts that help me administrate various tasks on IIS7 (Internet Information Services)

All the scripts do is trigger the IIS 7 Administrative VBS file, Modify IIS7 config and return succes and/or error messages, e.g.

%windir%\system32\inetsrv\appcmd set config -section:applicationPools /[name='DefaultAppPool'].processModel.loadUserProfile:false

I call the above script using this function, the $STDERR_CHILD + $STDOUT_CHILD are used to display success and/or error messages the VBS returns.

Func _loadUserProfile()
;open a hidden 'DOS' window and 'dir' root
$PID = Run(@ComSpec & " /c cscript /Nologo appcmd.vbs set config -section:applicationPools /[name='DefaultAppPool'].processModel.loadUserProfile:false", @SystemDir & "\inetsrv", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$Out = ""
While 1
   ;read one line from 'DOS' window
    $line = StdoutRead($PID)
   ;exit this loop if it is the last line from that window
    If @error Then ExitLoop
   ;concatenate all line into one variable
    $Out &= $line
WEnd
MsgBox(0, "IIS7 Admin Scripts", $Out)   
EndFunc;==>_loadUserProfile

While executing the [$PID], the programs dialog get the "unresponsive" status.

After the vbs script finishes, it will turn back to normal and displays the [stdoutRead] message

I tried to use [RunWait] instead of [Run], but it seems this doesn't work with the [stdoutRead] functions, right?

Is there another way i can make the program wait (and not become "unresponsive") untill the [$PID] command is complete finished and then continue with the rest of the script?

Thanks in advance,

RvdH

Edited by RvdH

Share this post


Link to post
Share on other sites



mmm, no one knows?

I know i can just place a sleep just after the command, allthough this might fix thing on one PC on a slow PC the problem may still arise, e.g.

$PID = Run(@ComSpec & " /c cscript /Nologo appcmd.vbs set config -section:applicationPools /[name='DefaultAppPool'].processModel.loadUserProfile:false", @SystemDir & "\inetsrv", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
sleep(10000);
oÝ÷ Ø&§j|¨ç(ø«'¹è·öî±änf¢µ©Ý²Ø¥Æ§­æJ×hºÔ^iÙb殶­s`¢b33cµBÒ'VåvB6öÕ7V2fײgV÷C²ö2767&BôæöÆövò6ÖBçf'26WB6öæfr×6V7Föã¦Æ6FöåööÇ2õ¶æÖSÒb33´FVfVÇDööÂb33µÒç&ö6W74ÖöFVÂæÆöEW6W%&öfÆS¦fÇ6RgV÷C²Â77FVÔF"fײgV÷C²b3#¶æWG7'bgV÷C²Â5uôDRÂb33cµ5DDU%%ô4ÄB²b33cµ5DDõUEô4ÄB

Share this post


Link to post
Share on other sites

mmm, no one knows?

I know i can just place a sleep just after the command, allthough this might fix thing on one PC on a slow PC the problem may still arise, e.g.

$PID = Run(@ComSpec & " /c cscript /Nologo appcmd.vbs set config -section:applicationPools /[name='DefaultAppPool'].processModel.loadUserProfile:false", @SystemDir & "\inetsrv", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
sleep(10000);
oÝ÷ Ø&§j|¨ç(ø«'¹è·öî±änf¢µ©Ý²Ø¥Æ§­æJ×hºÔ^iÙb殶­s`¢b33cµBÒ'VåvB6öÕ7V2fײgV÷C²ö2767&BôæöÆövò6ÖBçf'26WB6öæfr×6V7Föã¦Æ6FöåööÇ2õ¶æÖSÒb33´FVfVÇDööÂb33µÒç&ö6W74ÖöFVÂæÆöEW6W%&öfÆS¦fÇ6RgV÷C²Â77FVÔF"fײgV÷C²b3#¶æWG7'bgV÷C²Â5uôDRÂb33cµ5DDU%%ô4ÄB²b33cµ5DDõUEô4ÄB
You use Run() when reading the StdOut, but what do you mean with unresponsive ?

It sound pretty clear to me that, when your program is doing processing, it will not respond to other things unless you code them ..


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

No, not exactly what i meant, the program title bar says is is unresponsive (for a few seconds...until the vbs is finished)

after the VBS finishes the titlebar returns back to normal and script continues

Posted Image

Aangezien jij volgens mij ook aardig Nederlands bent maakt het niet uit dat het een Nederlandstalige screencap is, wel? :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

from the helpfile, about using StdoutRead

If at any time when this function is called (except for "peeking" as described below) there are no characters to be read from the stream, the StdoutRead function will block (pause) and not return until there are characters to be read from the stream. This means that the AutoIt process will be halted, and there will be no processing of hotkeys, GUI messages, etc. until the child process writes something to the STDOUT stream.

If you don't want the script to "Stall", you need to set the "peek" parameter. An example would be

$line = StdoutRead($PID,0,True)oÝ÷ ٩ݶ§jëh×6if $line>0 then $line = StdoutRead($PID)

or something like that.

Edited by improbability_paradox

Share this post


Link to post
Share on other sites

thx, improbability_paradox

It seems to work, it doesn't seem to stall... but unfortunatly it doesn't diplay output message either :)

I suggest reading up a bit more on StdoutRead, and experimenting. For example, when you use the "peak" option with a count of 0, the function will return the number of available characters that can be read. For example

$line = StdoutRead($PID,0,True)oÝ÷ Û¥×¥*.&j|ªÚr׫²Ø^­æ«y»­Víì­èhÁëÞ¯*.q©î±æ÷Þ­éí¥ªÚë^­ú+¶¢éí²ç!jËaÆ®¶­sbb33c¶ÆæRÒ7FF÷WE&VBb33cµBÂÓÅG'VRoÝ÷ Ùhbr"ZÞiÖ¥íæ¯j)ZnWªÚr׫±»­Â)eæ¯zØ^)íiËl¢ØZ·^*.q©eJ×hºÔ^iÖ j)ðØhºÛ¬x-ꮢÚ^jJ®¢Ú)¶*'Ü"X"½ì¨¹©e¡ûayÈZ­§-z»¨§¦[¬j|¦¢·­«aj÷yéÚu×J¨¹Æ§v(ëax%G­çèZ0x-¢G¦·v)àº{b*.ëp«r¢ìÖ®¶­sdÆö6Âb33cµ46÷VçE³%Тb33cµ46÷VçE³ÓÓ§vÆR&ö6W74W7G2b33cµB¢b33cµ46÷VçE³ÓÕ7FF÷WE&VBb33cµBÃÅG'VR¦bb33cµ46÷VçE³ÒfwC²b33cµ46÷VçE³ÒFVà¢b33c´ÆæSÕ7FF÷WE&VBb33cµBÂÓÅG'VR¢b33cµ46÷VçE³ÓÒb33cµ46÷VçE³Ð¦VæF`§vVæ@¦×6v&÷ÂgV÷C²gV÷C²Âb33c´ÆæR

Note that this code is untested, as I just wrote it in the browser, but it should show you what I am getting at.

Share this post


Link to post
Share on other sites

Func _loadUserProfile()
;open a hidden 'DOS' window and 'dir' root
$PID = Run(@ComSpec & " /c cscript /Nologo appcmd.vbs set config -section:applicationPools /[name='DefaultAppPool'].processModel.loadUserProfile:false", @SystemDir & "\inetsrv", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$Out = ""
While 1
   ;read one line from 'DOS' window
   ;$line = StdoutRead($PID)
    $line = StdoutRead($PID,0,True)
    if $line>0 then $line = StdoutRead($PID)
   ;exit this loop if it is the last line from that window
    If @error Then ExitLoop
   ;concatenate all line into one variable
    $Out &= $line
WEnd
MsgBox(0, "IIS7 Admin Scripts", $Out)   
EndFunc;==>_loadUserProfile

improbability_paradox, it no longer stalls.... but this way it does not display succes/error messages either

Share this post


Link to post
Share on other sites

While 1
    ;read one line from 'DOS' window
    ;$line = StdoutRead($PID)
    $line = StdoutRead($PID,0,True)
    if $line>0 then $line = StdoutRead($PID)
    ;exit this loop if it is the last line from that window
    If @error Then ExitLoop
    ;concatenate all line into one variable
    sleep(10)
    $Out &= $line
WEnd

If i put in a sleep, msgbox will display, only this time the message is prefix'ed by a whole lot of zero's

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Did you read my post #6? :)

Edit: another solution may be editing your code thus

While 1
    ;read one line from 'DOS' window
    if StdoutRead($PID,0,True)>0 then $line = StdoutRead($PID)
    ;exit this loop if it is the last line from that window
    If @error Then ExitLoop
    ;concatenate all line into one variable
    sleep(10)
    $Out &= $line
WEnd

although I do think that my post #6 may be better

edit: optimized code

Edited by improbability_paradox

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Oops missed that post :)

is seems to be working OK using:

$line = StdoutRead($PID,-1,True)
if $line > "" then $line = StdoutRead($PID)
oÝ÷ Ûú®¢×*.ºÇ­ç(uçë¢i²«-¦-Ü"X¶¸¡ûazènW¦Ê¡j÷°ØmìÞ®Êaz·(uë!¢é]vajÛh¡©Ý¥êájzj+z·¥¦åxGbµ©è¶«¶§}Ô²)ඡ׮©¢Ë}Ê°Ygyçm¡×ªÞÓ~¥wyú+yéíz¸§Ø^Â¥zZ(¥«­¢+Ù±½°ÀÌØí±¥¹)Ý¡¥±Ä(¸¸¸
Edited by improbability_paradox

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