Jump to content
Ketarin forum

Slight batch :loop problem


Omniferum
 Share

Recommended Posts

I'm just wondering why this piece of code doesn't work in the setup instructions

 

:loop
set run=
for /f "tokens=1 delims= " %a in ('tasklist ^| findstr /I autohotkey') do set run=%a
if defined run goto loop

 

It works in a batch file perfectly fine and as you can see i'm just trying to make it so that it basically waits for an existing AHK script to finish before starting the install of this one. Any pointers?

 

EDIT:

 

Actually one extra batch script problem i'm having.

 

for /F "tokens=*" %a in ('dir /b /s "{root}ThunderbirdPortable.exe"') do set folder=%~dpa

"{AHK}" "{startuppath}PA.ahk" "{file}" "%folder%"" "{appname:replace:Portable:}"

 

When I use that it gives an output of the thunderbird folder with extra stuff. Namely

"GPG

 

It is the GPG for thunderbird portable app but when I check the log %folder% is accurately resolving to JUST the folder path so i'm not sure why the extra stuff. The script works fine for everything else with ketarin built-in variables but for this one I need it to be a self-defined variable.

Link to comment
Share on other sites

That's all the log gives even though autohotkey.exe IS running, I am running it manually to make sure the :loop thing works. Again this seems to be the same sort of 'if defined' problem. The log isn't very helpful but as you can see it does set run to something, just ignores 'if defined'

 

12/11/2011 6:53:33 PM: ThunderbirdPortable: Executing command: :loop
12/11/2011 6:53:33 PM: ThunderbirdPortable: Executing command: set run=
12/11/2011 6:53:33 PM: ThunderbirdPortable: Executing command: for /f "tokens=1 delims= " %a in ('tasklist ^| findstr /I autohotkey') do set run=%a
12/11/2011 6:53:33 PM: ThunderbirdPortable: Executing command: if defined run goto loop
12/11/2011 6:53:33 PM: ThunderbirdPortable: Executing command: "Z:\Programs\Internet\Ketarin\AHK\autohotkey.exe" "Z:\Programs\Internet\Ketarin\PA.ahk" "Z:\Software\Automatically Updated\Private\ThunderbirdPortable_8.0_English.paf.exe" "Z:\Programs\Private\ThunderbirdPortable" "Thunderbird"
12/11/2011 6:53:36 PM: ThunderbirdPortable: Command result: Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
Z:\Programs\Internet\Ketarin>:loop
Z:\Programs\Internet\Ketarin>set run=
Z:\Programs\Internet\Ketarin>for /f "tokens=1 delims= " %a in ('tasklist ^| findstr /I autohotkey') do set run=%a
Z:\Programs\Internet\Ketarin>set run=AutoHotkey.exe
Z:\Programs\Internet\Ketarin>if defined run goto loop
Z:\Programs\Internet\Ketarin>"Z:\Programs\Internet\Ketarin\AHK\autohotkey.exe" "Z:\Programs\Internet\Ketarin\PA.ahk" "Z:\Software\Automatically Updated\Private\ThunderbirdPortable_8.0_English.paf.exe" "Z:\Programs\Private\ThunderbirdPortable" "Thunderbird"
Z:\Programs\Internet\Ketarin>

Link to comment
Share on other sites

  • 2 months later...

Hah, haven't touched this for a while. The 'if defined' command seems to work perfectly fine. It is having a problem with the whole goto loop. Anybody got a :loop in their batch file that is working successfully? I could just pipe this out to an external batch file but that would kind of defeat the purpose. Perhaps the way Ketarin interprets batch commands doesn't allow for loops?

 

25/01/2012 9:51:53 AM: FirefoxPortable: Executing command: :loop
25/01/2012 9:51:53 AM: FirefoxPortable: Executing command: set run=
25/01/2012 9:51:53 AM: FirefoxPortable: Executing command: for /f "tokens=1 delims= " %a in ('tasklist ^| findstr /I autohotkey') do set run=%a
25/01/2012 9:51:53 AM: FirefoxPortable: Executing command: if defined run goto loop
25/01/2012 9:51:53 AM: FirefoxPortable: Executing command: ::"Z:\Programs\Internet\Ketarin\AHK\autohotkey.exe" "Z:\Programs\Internet\Ketarin\PA.ahk" "Z:\Software\Ketarin Maintained Applications\Private\FirefoxPortable_9.0.1_English.paf.exe" "Z:\Programs\Private\FirefoxPortable" "Firefox"
25/01/2012 9:51:53 AM: FirefoxPortable: Command result: Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
Z:\Programs\Internet\Ketarin>:loop
Z:\Programs\Internet\Ketarin>set run=
Z:\Programs\Internet\Ketarin>for /f "tokens=1 delims= " %a in ('tasklist ^| findstr /I autohotkey') do set run=%a
Z:\Programs\Internet\Ketarin>set run=AutoHotkey.exe
Z:\Programs\Internet\Ketarin>if defined run goto loop
Z:\Programs\Internet\Ketarin>::"Z:\Programs\Internet\Ketarin\AHK\autohotkey.exe" "Z:\Programs\Internet\Ketarin\PA.ahk" "Z:\Software\Ketarin Maintained Applications\Private\FirefoxPortable_9.0.1_English.paf.exe" "Z:\Programs\Private\FirefoxPortable" "Firefox"
Z:\Programs\Internet\Ketarin>

25/01/2012 9:52:14 AM: FirefoxPortable: Executing command: :loop
25/01/2012 9:52:14 AM: FirefoxPortable: Executing command: set run=
25/01/2012 9:52:14 AM: FirefoxPortable: Executing command: for /f "tokens=1 delims= " %a in ('tasklist ^| findstr /I autohotkey') do set run=%a
25/01/2012 9:52:14 AM: FirefoxPortable: Executing command: if defined run echo 
25/01/2012 9:52:14 AM: FirefoxPortable: Executing command: ::"Z:\Programs\Internet\Ketarin\AHK\autohotkey.exe" "Z:\Programs\Internet\Ketarin\PA.ahk" "Z:\Software\Ketarin Maintained Applications\Private\FirefoxPortable_9.0.1_English.paf.exe" "Z:\Programs\Private\FirefoxPortable" "Firefox"
25/01/2012 9:52:14 AM: FirefoxPortable: Command result: Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
Z:\Programs\Internet\Ketarin>:loop
Z:\Programs\Internet\Ketarin>set run=
Z:\Programs\Internet\Ketarin>for /f "tokens=1 delims= " %a in ('tasklist ^| findstr /I autohotkey') do set run=%a
Z:\Programs\Internet\Ketarin>set run=AutoHotkey.exe
Z:\Programs\Internet\Ketarin>if defined run echo 

Z:\Programs\Internet\Ketarin>::"Z:\Programs\Internet\Ketarin\AHK\autohotkey.exe" "Z:\Programs\Internet\Ketarin\PA.ahk" "Z:\Software\Ketarin Maintained Applications\Private\FirefoxPortable_9.0.1_English.paf.exe" "Z:\Programs\Private\FirefoxPortable" "Firefox"
Z:\Programs\Internet\Ketarin>

Link to comment
Share on other sites

The thing is, it's not really a batch file - it's a shell script. The difference is that a batch file is a reentrant physical script, while this is executed to a shell prompt as a series of commands (not exactly, but similar to what you'd expect from a sendkeys call or something). I don't think a loop is possible without using either a C# script or piping to an external script.

Link to comment
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
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.