Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Command Won't Run From Batch File?

- - - - -

  • Please log in to reply
3 replies to this topic


  • Member
  • 8 posts
  • Joined 31-May 07
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.

How to remove advertisement from MSFN



    Senior Member

  • Developer
  • 678 posts
  • Joined 21-March 07
in a batch file use %%G (on the command line %G)



Edited by wimb, 09 February 2012 - 02:14 PM.


MBR-Backup - Make-PE3



  • Member
  • 8 posts
  • Joined 31-May 07
D'oh! :blushing:

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

Thanks!! :thumbup



    Advanced Member

  • Member
  • PipPipPip
  • 420 posts
  • Joined 09-September 04
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 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users