Solved

Need some help in Batch file assigning variable value ?

Posted on 2016-10-17
4
75 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 24

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 24

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Synchronize a new Active Directory domain with an existing Office 365 tenant
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

839 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