Jump to content

Recommended Posts

Posted

Hallo,

I try to make bootable usb ssd with few windows images for my company. I found somthing like this: http://www.peppercrew.nl/index.php/2015/02/automated-usb-wim-deployment/.

This would be perfect, but I have wim images that are 20 Gigabyte (fat32 is only for 4GB files). I made two partitions on usb drive one for boot.wim etc and other for other files. Can someone help me with scirpt in startnet.cmd. I have to modify the script so that not only detect usb drive but also the name from volume with wim images and install chosen form menu os. 

Thank you in advance for your help!

Bing

wpeinit 
@ECHO OFF 
C: 
CD\ 
CLS

:MENU

ECHO ============= Installeren Thin Image ============= 
ECHO ————————————————– 
ECHO 1.  Thinclient T5740 
ECHO ————————————————– 
ECHO 2.  ThinPC 8200 
ECHO ————————————————– 
ECHO ==========PRESS ‘Q’ TO QUIT========== 
ECHO.

SET INPUT= 
SET /P INPUT=Please select a number:

IF /I ‘%INPUT%’==’1’ GOTO Selection1 
IF /I ‘%INPUT%’==’2’ GOTO Selection2 
IF /I ‘%INPUT%’==’Q’ GOTO Quit 
CLS

ECHO ============INVALID INPUT============ 
ECHO ————————————- 
ECHO Please select a number from the Main 
echo Menu [1-2] or select ‘Q’ to quit. 
ECHO ————————————- 
ECHO ======PRESS ANY KEY TO CONTINUE======

PAUSE > NUL 
GOTO MENU 
CLS 
:Selection1
for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype 2^>NUL`) do (

if %%l equ 2 ( 
echo %%i is a USB drive. 
        ) 
Diskpart /s %%i\diskpart\diskpart.txt 
cd\ 
%%i\Imagex.exe /apply %%i\Thinclient\TC.WIM 1 C: 
        ) 


:Selection2
for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype 2^>NUL`) do (

if %%l equ 2 ( 
echo %%i is a USB drive. 
        ) 
Diskpart /s %%i\diskpart\diskpart.txt 
cd\ 
%%i\Imagex.exe /apply %%i\Thinclient\TC2.WIM 1 C: 
        ) 

:Quit 
CLS 
ECHO —————————————————- 
ECHO =============PRESS ANY KEY TO CONTINUE============== 
ECHO —————————————————- 

PAUSE>NUL 
EXIT

Posted

Do not put all that into startnet.cmd. Make your own .cmd and call it within startnet.cmd.

Change your diskpart script to make your destination volume a different letter than C.

Posted

Thank you for yours tip. Sure I can run this from other cmd other bat file. But how can I modify script? I need query for letter and volumename in this one script. Now I have only letter but this is not enough :(.

Posted

I have now modified the so code:

wpeinit
@ECHO OFF 
C: 
CD\ 
CLS

:MENU

ECHO ============= Installeren Thin Image ============= 
ECHO ————————————————– 
ECHO 1.  Windows 7 64bit installieren  
ECHO ————————————————– 
ECHO 2.  Windows 10 LTSB installieren  
ECHO ————————————————– 
ECHO ==========Druecke die Taste ‘Q’ zum abbrechen========== 
ECHO.

SET INPUT= 
SET /P INPUT=Bitte waehlen Sie Auswahl:

IF /I ‘%INPUT%’==’1’ GOTO Auswahl1 
IF /I ‘%INPUT%’==’2’ GOTO Auswahl2 
IF /I ‘%INPUT%’==’Q’ GOTO Quit 
CLS

ECHO ============INVALID INPUT============ 
ECHO ————————————- 
ECHO Please select a number from the Main 
echo Menu [1-2] or select ‘Q’ to quit. 
ECHO ————————————- 
ECHO ======PRESS ANY KEY TO CONTINUE======

PAUSE > NUL 
GOTO MENU 
CLS 
:Auswahl1
for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,VolumeName 2^>NUL`) do (

if %%l equ wim (
echo %%i is a USB drive. 
        ) 
Diskpart /s %%i\mbr.txt 
cd\ 
%%i\Imagex.exe /apply %%i\win7_64bit_2016.wim 1 C: 
        ) 


:Auswahl2
for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,VolumeName 2^>NUL`) do (

if %%l equ wim (
echo %%i is a USB drive. 
        ) 
Diskpart /s %%i\gpt.txt 
cd\ 
%%i\Imagex.exe /apply %%i\win10.wim 1 C: 
        
        ) 

:Quit 
CLS 
ECHO —————————————————- 
ECHO =============PRESS ANY KEY TO CONTINUE============== 
ECHO —————————————————- 

PAUSE>NUL 
EXIT

 but won't work and I don't know why :(. 

Posted

Maybe you should take a step back and provide some info.

What is the output that you have when running this simple batch:
 

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do (
ECHO %%A %%B
IF /I "%%B"=="wim" SET wimdrive=%%A
)
SET wimdrive

(possibly the "equ" test is not working in your batch :unsure:)

BTW there are a few  things that can be bettered in your batch, and seemingly it is missing the appropriate bcdboot command :dubbio:(after the imagex one, otherwise how is the system made bootable?)

jaclaz


 

Posted (edited)

Thank you for your answer. Yes I have forgotten bcdboot, but I have it.

bcdboot W:\Windows /s S: /f ALL (for Windows 10 PC with UEFI and BIOS)

and

bcdboot C:\Windows /s S: (for Windows 7)

Output from your batch code:

boot.jpg

Edited by bingloverld
Posted

Good, so the "normal" IF test finds the drive.

I personally would change the "logic" of the batch, having it trying to find the drive with the "wim" label BEFORE asking the user to choose between #1 and #2 (as a side-side not you don't need a /I switch in IF if the comparison is with numbers, there is not a "small case 1" and a "CAPITAL CASE 1 ;)), I mean, if the drive is not found, there is not much sense in asking the user to choose between 1 and 2 and provide an error after the choice.

Then, I would probably want to disallow *anything* but 1,2 and q/Q in the SET /P, you can do this with something *like*:

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
:loop
SET "Nums="
SET /P "Nums=Please Enter 1,2 or Q: "
IF NOT DEFINED Nums echo Invalid input & goto :loop
SET "Nums=!Nums:~0,1!"
for /f "delims=12qQ" %%? in ("!Nums!") do echo Invalid input & goto :loop
SET Nums
GOTO :EOF

jaclaz


 


 

Posted (edited)

Ok. I have paste this script here als example what I have found on Internet. I am sorry.

I don't want chose anything. I am making only one Windows installation (one install.wim) per WinPE, also I don't need chose from menu which OS should be installed.

I need script that make

diskpart (easy)
imagex (Windows 7 Enterprise) or dism (Windows 10 Enterprise 2015 LTSB) (here I have problem, with second partition on my USB ssd drive, thats why I need script that als first detect usb drive and second volume name and output this to imagex or dism)
bcdboot  (easy)

That's all what I need :)

I am sorry for misrepresentation.

Thank you for your time and help!!!

Edited by bingloverld
Posted

I am failing to follow you.

You have a single script on a single PE or two different scripts (and two different PE's) for Windows 7 (BIOS/MBR) and Windows 10 (UEFI/GPT)?

Is this what you want?

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SET wimdrive=
FOR /F "tokens=1,2 " %%A in ('wmic logicaldisk get caption^,VolumeName 2^>NUL') do (
ECHO %%A %%B
IF /I "%%B"=="wim" SET wimdrive=%%A
)
IF DEFINED wimdrive ECHO A drive with label "wim" has been found: %wimdrive% &&PAUSE&&GOTO :_doit
ECHO An error occurred can't find wimdrive :(
PAUSE
GOTO :EOF

:_doit
ECHO Just doin' it

::insert here diskpart commmands
::insert here imagex or Dism commands using %wimdrive% as the source drive letter
::insert here bcdboot commands

ECHO All done
PAUSE

jaclaz


 

Posted

1) I am sorry that I write not clear.

two different scripts (and two different PE's) for Windows 7 (BIOS/MBR) and Windows 10 (UEFI/GPT)?

Yes, this is perfect! 

Thank you jaclaz!

2) Can I use dism when wim image of Windows 7 was created with imagex ?

Posted

#2 Why not?

After all you are applying a .wim, nothing more, the point might be with the speciific DISM version, I seem to remember that for some operations you need the AIK/WAIK or the 8 version :unsure: but that won't apply to "apply" (pardon me the pun).

You can try using JFX's nice tool to get the various versions and experiment with them:
 

Or you could also try the Wimlib:

https://wimlib.net/
 

jaclaz
 

Posted (edited)

Ok, so should work. I have WinPE ver. 10. 

Is dism better because you don't need prepare it (is in all WinPE etc), as you need with imagex? Or is another advantage?

Thank you!

Edited by bingloverld
Posted
49 minutes ago, bingloverld said:

Ok, so should work. I have WinPE ver. 10.

 This brings us back to the question about the number of PE's in use. :dubbio:

I mean, a boot.wim for the PE is probably something like 200-300 Mb or so and you will have two of them differing between them only by one occurence of "win10.wim" vs. "win7_64bit_2016.wim" in a batch file, and of course (IF you want to be able to install the one or the other OS, 7 or 10) you will need anyway to make a choice (between the first PE that installs the Windows 7 and the second PE that installs the Windows 10) :unsure:

jaclaz


 

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...