2

I'm running a batch script that calls the binary NiniteOneTrial to install a bunch of apps listed in the "applist.txt". This works great, but I want to see if there is a way to setup a variable that prints to the screen (echo) the app that is currently being installed (per the applist.txt calls):

Basically, want to replace the %%CURRENTTASKFROMLIST%% with the app currently being installed from that list.

set CACHEPATH=\\server-01\local_apps\Ninite\netcache
set file_list=C:/ninite/applist.txt

:appinstall
for /f %%1 in (%file_list%) do (
  echo . . . . . . . . . . . . . . . . [ Installing %%CURRENTTASKFROMLIST%% ]
  cmd /c C:/ninite/NiniteOneTrial.exe /disableautoupdate /disableshortcuts /allusers /select %%1 /silent . /cachepath %CACHEPATH%
)
6
  • I'm confused. What is it that you want to echo? I.e., what is CURRENTTASKFROMLIST supposed to be? Do you want to echo something different from the %%1 you are using on the next line? Commented Oct 22, 2011 at 0:17
  • The applist.txt file has a list of applications. The :appinstall segment calls each item on that list. I get the echo: "Installing xxx" for every single item that is ran, but I want to make it so the 'xxx' a certain variable that actually tells me which item is being ran at the time. Sorry, I'm a newbie programmer and my terminology is still pretty green :) Commented Oct 22, 2011 at 0:37
  • 1
    I'm still not sure what you're trying to print. Suppose file_list contains the line "app1". Do you want to print "Installing app1"? If so, then just use %%1 like you're doing on the next line. Commented Oct 22, 2011 at 0:49
  • I thought I had tried that :|, did it again and viola!. Thanks! Commented Oct 22, 2011 at 2:12
  • 1
    Excuse me. Your Batch file run just by chance. All known documentation said that FOR replaceable parameters must be a LETTER (uppercase or lowercase) because the %-digit pair is reserved for the Batch file parameters. Although the %-digit also works in FOR (just made a test), this behaviour is completely undocumented! For example for %%1 in (%1) do echo %%1 works in a Batch file, but for %1 in (%1) do echo %1 in the command-line also works with nonsense result. PLEASE, don't use %-digit in FOR, change it for %-letter! :) Commented Oct 27, 2011 at 0:47

1 Answer 1

2

From your question and comments it sounds like you want to just use %%1 where you have %%CURRENTTASKFROMLIST%%. The %%1 in the for loop will provide you with the app name that is currently being installed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.