It is currently Wed Jun 20, 2018 12:02 am


Register for Windows Forums


New posts Register

Register for Windows Forums now to gain access to: post messages, download free books, competitions for great prizes, and get to know others. Members also see NO ADVERTS. Join today!




 Page 1 of 1 [ 3 posts ] 
Message Author
 
 Post subject: Batch file help (Variables)
New postPosted: Fri Feb 11, 2011 7:27 pm 

It is possible to set the output of a command as a variable in a batch file?

If i run dism /get-wiminfo /wimfile:%wloc% | find /i /c "index" i'll get the required ouput but how can i then set that output as a variable?



_________________
Image
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar
Site Admin
Site Admin
Windows Guru²
Windows Guru²

Joined: Sat Jun 07, 2008 9:08 am
Posts: 3186
Thanks given: 375 times
Thanks received: 441 times
Location: 0x7C00
OS: 8 RT
 Profile E-mail  
 
Offline
 
 Post subject: Re: Batch file help (Variables)
New postPosted: Thu Mar 31, 2011 1:56 pm 

Did you ever figure this out? I remember looking around but I am not very experienced with batch and didn't come to a solution...



_________________
Image
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar
Site Admin
Site Admin
Windows Guru²
Windows Guru²

Joined: Sun Mar 02, 2008 8:33 pm
Posts: 2813
Thanks given: 424 times
Thanks received: 213 times
OS: 8 Pro
 Profile E-mail  
 
Offline
 
 Post subject: Re: Batch file help (Variables)  Topic is solved
New postPosted: Fri Apr 01, 2011 7:07 am 
For this post the author Stu has received gratitude : Rich

Yeah i got it in the end.

Here's the code in context.

// Once a valid path has been determined, we search for how many index numbers the image has. If less than one is found an error is thrown.
)
for /f "tokens=*" %%a in (
'dism /get-wiminfo /wimfile:%var1% ^| find /c /i "index"'
) do (
set var8=%%a
)
if %var8% EQU 0 (
echo. && echo No image index numbers could be found!
echo I'll assume you made a typo in the path or your image is borked. && echo. && pause && goto:WIMLOC1



_________________
Image
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar
Site Admin
Site Admin
Windows Guru²
Windows Guru²

Joined: Sat Jun 07, 2008 9:08 am
Posts: 3186
Thanks given: 375 times
Thanks received: 441 times
Location: 0x7C00
OS: 8 RT
 Profile E-mail  
 
Offline
Display posts from previous:  Sort by  
 Page 1 of 1 [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 36 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

cron