MSFN Forum: Command Won't Run From Batch File? - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Command Won't Run From Batch File? Rate Topic: -----

#1 User is offline   Coucher 

  • Group: Members
  • Posts: 8
  • Joined: 31-May 07

Posted 09 February 2012 - 01:48 PM

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.


#2 User is offline   wimb 

  • Senior Member
  • Group: Developers
  • Posts: 633
  • Joined: 21-March 07

Posted 09 February 2012 - 02:14 PM

in a batch file use %%G (on the command line %G)

http://ss64.com/nt/for_f.html

:)

This post has been edited by wimb: 09 February 2012 - 02:14 PM


#3 User is offline   Coucher 

  • Group: Members
  • Posts: 8
  • Joined: 31-May 07

Posted 10 February 2012 - 06:59 AM

D'oh! :blushing:

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


Thanks!! :thumbup

#4 User is offline   os2fan2 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 417
  • Joined: 09-September 04

Posted 12 March 2012 - 01:25 AM

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)

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy