Solved

Need some help in Batch file assigning variable value ?

Posted on 2016-10-17
4
66 Views
Last Modified: 2016-10-17
People,

Can anyone here please assist me with the batch script below:

C:\WINDOWS\system32>bcdedit /store C:\WinPE_Combined\Media\Boot\BCD /enum | find "osdevice"
osdevice                ramdisk=[boot]\sources\boot.wim,{7619daa8-fafa-11d9-b411-000476eba66e}

Open in new window


I need to assign like this OSID={7619daa8-fafa-11d9-b411-000476eba66e}

Thanks in advance.
0
Comment
  • 2
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
NVIT earned 500 total points
ID: 41847518
for /f "tokens=2 delims=," %%a in ('bcdedit /store C:\WinPE_Combined\Media\Boot\BCD /enum ^| find "osdevice"') do (
  set OSID=%%a
  echo OSID=%OSID%
)

Open in new window

1
 
LVL 7

Author Comment

by:Senior IT System Engineer
ID: 41847537
THanks NVIT,

but somehow:

%%a was unexpected at this time.

Open in new window

0
 
LVL 23

Assisted Solution

by:NVIT
NVIT earned 500 total points
ID: 41847547
Because it's supposed to be saved in a bat file.
If you run it on the the CMD line, change all the %% to %
0
 
LVL 7

Author Closing Comment

by:Senior IT System Engineer
ID: 41847622
Thanks man !
yes it works.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Synchronize a new Active Directory domain with an existing Office 365 tenant
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now