Sup /g/,
I have an old Windows machine I need to automate something on, bash and powershell aren't available to me, and I'm not sure how to do what I'm trying to do with only batch scripting available.
essentially, I'd like to have somewhere, in the batch file, in a text file, wherever
arg1 arg2 arg3 etc.
and have the batch file repeatedly execute...
command $arg staticarg anotherstaticarg
...until there are no arguments left.
Yeah, I know I can just do
command $arg1 staticarg anotherstaticarg
command $arg2 staticarg anotherstaticarg
command $arg3 staticarg anotherstaticarg
...but the list of variable arguements is likeky going to change often, so I don't want to do that.
Any ideas /g/?
Should I just install Cygwin and do this in bash?
>>61948642
lrn2goto
why would you waste your time with batch when you already know you can do it in bash?
batch was not meant for this sort of thing.
RTFM
https://en.wikibooks.org/wiki/Windows_Batch_Scripting#FOR
>>61948709
I know, I've just been asked to "not install anything" unless I absolutely have to.
>>61948642
Just kill that NT4 box
>>61948726
This is a stupid idea. You don't understand CMD, aren't really a hot shit programmer. You'll probably wreck shit if you use it.
Install bash & play it safe.
>>61948725
Yeah I've looked at this, but have no idea where to even start, I haven't touched batch in around 20 years.
I'm probably going to just use Windows task scheduler to make a different machine on the network (that has Cygwin) generate a crappy batch file using the...
command $arg1 staticarg anotherstaticarg
command $arg2 staticarg anotherstaticarg
command $arg3 staticarg anotherstaticarg
...method.
>>61948754
2000 Advanced Server, you were close.
It has to do with DNR reporting at the water department.
>>61948759
Haven't used cmd once but maybe you can try this by putting each arg on new line on list.txt.for /f "tokens=*" %%a in (list.txt) do @command %%a staticarg anotherstaticarg
I'm a batch programmer so I think I can help, but you are going to have to give me more to work with because I don't understand what you are trying to achieve here.
Explain in baby steps exactly what you want this script to do and I will post you the code to do it.
>>61948725
>%i is to be used from the command line while %%i is to be used from a batch
Who thought of this?
>>61948806
fixedtext $variabletext fixedtext fixedtext
I'm going to be executing the same command multiple times.
Argument 2 and argument 3 will always be the same.
Argument 1 is dymanic, I'd like to retrieve it from somewhere, I don't care where.
>>61948790
This worked for what I want to do, thanks.
>>61948642
You install a GNU/Linux distro on it so that """old'''''' computer will feel as new again. The you google how bash works and solve your problem in 1 minute.
for /f "delims=" %%X in ('args.txt') do (command %%X staticarg anotherstaticarg)
>>61948882
I'm using gov. provided software on a server I don't own. Said software only runs on Win2k Adv. Server
I already know how bash works :-)
>>61948932
best of luck, anon!
OP if possible, you can run a somewhat limited bash via busybox for windows
https://frippery.org/busybox/
The bash is kinda old, but it beats scripting with Batch.
>>61948964
I've already finished what I was trying to accomplish, this >>61948790 did what I needed.
Irrelevant to OP's question, do you know a batch interpreter that can be run on Linux?
>>61948642
Download busybox.exe and do it in the busybox shell. It's under a megabyte.
>>61949057$ wine cmd
>>61948820
Don't question it it's microsoft, probablly some weird compatibility issue.