Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Need some help in Batch file assigning variable value ?

Posted on 2016-10-17
Medium Priority
Last Modified: 2016-10-17

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.
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 25

Accepted Solution

NVIT earned 2000 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


Author Comment

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

but somehow:

%%a was unexpected at this time.

Open in new window

LVL 25

Assisted Solution

NVIT earned 2000 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 %

Author Closing Comment

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

Featured Post

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

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

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

715 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