Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


Coucher

Command Won't Run From Batch File?

4 posts in this topic

Ok, here's some background on what I'm trying to do...

Trying to have a USB HDD with WinPE 3.0 on it and multiple WIM files on the HDD for various types of machines that I build.

What I have currently is the above, and from the startnet.cmd I call a batch file (build_machine.bat) that invokes diskpart to prepare the disk, then corrects the boot sector using bootsect.exe, then applies image.wim to the target disk. What I've been doing is just renaming whatever <machine type>.wim file to image.wim for the ones I was doing the most of at that time.

Trying to build some automation into the process where the batch file queries the BIOS info from the registry and get's the machine family name, sets that to a variable (%image%), then invokes imagex pointing to %image%.wim.

The problem I'm running into is with the command that I'm using to query the registry and set the returned value as a system variable. If I manually execute the command via the command prompt within WinPE it works perfectly, sets the system variable exactly as it should, however when I take that exact command and add it as a line in my build_machine.bat file, it errors out.

Here's the query command:

for /f "tokens=3,*" %a in ('reg query HKLM\HARDWARE\DESCRIPTION\System\BIOS /v SystemFamily ^| findstr SystemFamily') do set image=%b

Which works fine run from the command prompt, but when run from within the batch file errors out with "b was unexpected at this time."

Any ideas?

Thanks in advance.

0

Share this post


Link to post
Share on other sites

D'oh! :blushing:

Not sure how I missed something so simple. After changing to double % marks it works perfectly.

Thanks!! :thumbup

0

Share this post


Link to post
Share on other sites

You could use F Westlake's 'conset', which can read registry values into the current environment, eg

conset /k zdir=HKLM\Software\wendy\folders\%1

This line looks for whatever %1 is, and returns the value to zdir. eg batch zsource might set zdir=l:\save\cdata\batch\zsource

(the folder containing the source for batch files)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.