for loop - Behaviour of parallel running same batch files -


for fun reasons wrote batch-file typing 100 random upper-/lowercase letters whereever click to. turned out quite slow decided start command line simple for-loop more chars in less time: for /l %m in (1,1,3) (start bat.bat) starting shell in folder file located at.

beeing curious if got 300 characters went this website shows written characters in realtime , came interesting observation: 293 letters (+- 5 or so) , not expected 300 ones. assume because of parallel running processes. can see writing starts in blocks of 3 characters , 1 or 2 characters missing , continues on whole script duration.

now question: parallel running of same batch-file affect each others process?
below code of file (and yes know done way shorter , more efficient):

@if (@codesection == @batch) @then @echo off setlocal enabledelayedexpansion  timeout /t 3 set sendkeys=cscript //nologo //e:jscript "%~f0" /l %%g in (1,1,100) ( set /a grkl=!random! %%2 if "x!grkl!"=="x0" ( !sendkeys! "z" ) else ( !sendkeys! "z" ) ) exit @end // jscript section var wshshell = wscript.createobject("wscript.shell"); wshshell.sendkeys(wscript.arguments(0)); 

i suppose it's bug in sendkeys itself.

i simplified code to

@if (@codesection == @batch) @then @echo off setlocal enabledelayedexpansion  ping localhost -n 4 > nul set sendkeys=cscript //nologo //e:jscript "%~f0" /l %%g in (1,1,100) (     !sendkeys! "%1" ) exit @end // jscript section var wshshell = wscript.createobject("wscript.shell"); wshshell.sendkeys(wscript.arguments(0)); 

and test use

(for /l %n in (1 1 2) ( start /b geist.bat %n) ) & set /p var= 

this works perfect, outputs 200 characters.
but if change geist.bat %n fixed value geist.bat 1, got less 200 characters.
, if change geist.bat z got z lower case z characters!
fails when use fixed string in wshshell.sendkeys("p");

if use 1 thread for /l %n in (1 1 1) works perfect again.

so conclusion sendkey functionallity somehow broken.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -