Jump to content

startnet.cmd / diskpart


Recommended Posts

Because i wan't to automate as much as possible by restoring or making a image and want to delete a disk with all partitions and then off course create a new partition NTFS with use of Winpe and WDS/WAIK etc for windowsxp SP2 clients.

Reading thru google says that i best use diskpart for the partitions and startnet.cmd to start diskpart.

But i don't understand how to edit startnet.cmd to start a diskpart file and how to make a diskpart file to wipe out the disk and create new partition for restoring to that partition.

I have read that i must mount a image with imagex but how do i edit the startnet.cmd then?

Must i make a startnet.cmd in every image i got?

Link to comment
Share on other sites


You'll have to create a text file with the command you want and add this to your startnet.cmd:

DISKPART /S FILE.TXT

My text file has this:

SELECT DISK 0
CLEAN
CREATE PARTITION PRIMARY
FORMAT FS=NTFS LABEL="Windows XP" QUICK
SELECT PARTITION 1
ASSIGN LETTER=C
ACTIVE
EXIT

Thx, but how do i add the textfile to a startnet.cmd?

Link to comment
Share on other sites

Thx, but how do i add the textfile to a startnet.cmd?

You do not "add" FILE.TXT to startnet.cmd

you add the line:

DISKPART /S FILE.TXT

inside startnet.cmd, with notepad or other "pure text" editor.

this invokes diskpart using the FILE.TXT as a series (or batch) of commands that will be executed automatically.

FILE.TXT, with the contents of the previous post or your custom ones, must obviously be in the same directory of startnet.cmd.

jaclaz

Link to comment
Share on other sites

Thx, but how do i add the textfile to a startnet.cmd?

You do not "add" FILE.TXT to startnet.cmd

you add the line:

DISKPART /S FILE.TXT

inside startnet.cmd, with notepad or other "pure text" editor.

this invokes diskpart using the FILE.TXT as a series (or batch) of commands that will be executed automatically.

FILE.TXT, with the contents of the previous post or your custom ones, must obviously be in the same directory of startnet.cmd.

jaclaz

Ok. The part of file.txt and diskpart is clear to me, but the startnet.cmd not yet. I have read that startnet.cmd is in the windows\system32 folder on every image. What must i do to add the command diskpart etc to startnet.cmd?

Mount a image and then? or make a startnet.cmd of my own with notepad but how to add it to a image?

Link to comment
Share on other sites

Thx, but how do i add the textfile to a startnet.cmd?

You do not "add" FILE.TXT to startnet.cmd

you add the line:

DISKPART /S FILE.TXT

inside startnet.cmd, with notepad or other "pure text" editor.

this invokes diskpart using the FILE.TXT as a series (or batch) of commands that will be executed automatically.

FILE.TXT, with the contents of the previous post or your custom ones, must obviously be in the same directory of startnet.cmd.

jaclaz

Ok. The part of file.txt and diskpart is clear to me, but the startnet.cmd not yet. I have read that startnet.cmd is in the windows\system32 folder on every image. What must i do to add the command diskpart etc to startnet.cmd?

Mount a image and then? or make a startnet.cmd of my own with notepad but how to add it to a image?

Can you help me with this, i can't really find how to edit / make the startnet.cmd and how to add it etc?

Link to comment
Share on other sites

I am not sure I actually can.

I am failing to see what your question actually is.

Do you already have a startnet.cmd?

Read this first thing:

http://technet.microsoft.com/en-us/library/cc766521.aspx

startnet.cmd is a simple batch file (under NT/2K/XP/2003 batch files can have both the .bat or .cmd extension, the latter is the "proper" one) that is autoexecuted, you may think at it like the old AUTOEXEC.BAT of DOS/Win9x/Me.

It is a plain TEXT .txt file (that you can make with Notepad) with it's extension changed to .cmd.

Any batch command inside the startnet.cmd is executed.

You either add the said line to an existing startnet.cmd or you create with notepad a new file named startnet.cmd adding to it that line.

The said line:

DISKPART /S FILE.TXT

will call DISKPART.EXE with the /S parameter (which makes diskpart parse a Script file) and feed to it the name of such a file: FILE.TXT

FILE.TXT, with the contents seen before is a simple sequence of commands, that diskpart will execute, exactly as if they were given one by one on command line.

jaclaz

Link to comment
Share on other sites

Thx, but how do i add the textfile to a startnet.cmd?

You do not "add" FILE.TXT to startnet.cmd

you add the line:

DISKPART /S FILE.TXT

inside startnet.cmd, with notepad or other "pure text" editor.

this invokes diskpart using the FILE.TXT as a series (or batch) of commands that will be executed automatically.

FILE.TXT, with the contents of the previous post or your custom ones, must obviously be in the same directory of startnet.cmd.

jaclaz

Ok. The part of file.txt and diskpart is clear to me, but the startnet.cmd not yet. I have read that startnet.cmd is in the windows\system32 folder on every image. What must i do to add the command diskpart etc to startnet.cmd?

Mount a image and then? or make a startnet.cmd of my own with notepad but how to add it to a image?

Can you help me with this, i can't really find how to edit / make the startnet.cmd and how to add it etc?

I think i know a little more.

I am mounting the boot.wim. ype in: edit d:\wds\mount\startnet.cmd (path where i mounted boot.wim).

After the wpinit i put in the rule: diskpart /s diskpart.txt (this is a little confusing: diskpart.txt must excist but where do i put the diskpart.txt, must i also choose in the mounted boot.wim: edit c:\diskpart.txt and put in the lines?)

And must i do this also voor the install image?

Must i then add the boot.wim and install.wim to the wds first remove then add or is replace enough?

Link to comment
Share on other sites

surfetje,

there is no need to quote entire previous posts, it only makes the topic pretty much unreadable.

About the where to put diskpart.txt, try to look at it from another angle, when the startnet.cmd will be executed, at a certain point it will call diskpart.exe, and diskpart.exe will call diskpart.txt (without any drive/path specified).

Isn't the answer easy? :unsure:

Diskpart.txt must be anywhere it can be found by diskpart.exe at the time it will run, i.e. in the same directory as startnet.cmd, which, as detailed in the given link, should be %SYSTEMROOT%\System32 of the image.

I have no idea how you are mounting the .wim image, and what do you mean by "d:\wds\mount\startnet.cmd (path where i mounted boot.wim)" and "c:\diskpart.txt"

:w00t:

Maybe we are using different "terms", but I really do not understand what you mean.

jaclaz

Link to comment
Share on other sites

With mounting to d"\wds\mount i mean: the image is mounted with imagex. I have read that i must mount the image to edit startnet.cmd and diskpart.

When i don't mount the image the startnet.cmd cannot be edited?

But on a article on the internet i saw it is also possible to use Unattend.xml fot automating like formatting etc. in the windowsPE phase, in combination with windowsXP. Can i use unattend.xml instead of startnet.cmd? Because this unattend can be edited with WAIK which makes it easyer. I have tried it already but unattend doesn't do anything when i make use of it with windowsxp..

Link to comment
Share on other sites

Of course the .wim needs to be mounted, how would you access it's contents otherwise?

Maybe you should use one of the GUIS available:

http://www.autoitscript.com/gimagex/

http://www.msfn.org/board/GImageX-and-WIMM...ls-t107920.html

http://www.911cd.net/forums//index.php?showtopic=20706

http://www.boot-land.net/forums/?showtopic=3001

But, no offence whatever intended :), you appear to have not yet fully grasped the theory behind the use of .wim images.

If I may give you some advice:

You should re-study the available documentation and online one, start here:

http://technet.microsoft.com/en-us/library/cc721929.aspx

Initially do try building normal, simple deploying images, to get the hang of the procedure, and only later introduce variations, unattended install, partitioning and the like.

I suspect that at the moment you are attempting to have "everything an now" without being sufficiently familiar with the basics. :unsure:

jaclaz

Link to comment
Share on other sites

  • 7 months later...

to use just a single cmd to perform the diskpart funtions; try somthing like...

@echo off
ver
set script=%temp%\vdisk.txt
>"%script%" echo create vdisk file=c:\Win7_x86.vhd maximum=%1
>>"%script%" echo select vdisk file=c:\Win7_x86.vhd
>>"%script%" echo attach vdisk
>>"%script%" echo exit
diskpart /s "%script%"

info on above: cmd is part of my windows 7 vhd based setup script placed in the pe system32 dir.

:)

Link to comment
Share on other sites

Hi to all,

reagrding this topic, i have some doubts:

1) startnet cmd is not in my system32 folder, so i suppose that i need to create it in the pc that i want to clone. -> IS it true?

2) how can i apply the image from the same script. This is my final scenario: i have a boot cd with os image and all the need to start ImageX enviroment. I can use the commands listed above in order to clean, create and format the partition, but how can i apply the image in this new partition? I don't know if in my final target pc there is one or more hd, so i can not refer to, in example, d:\myimage, because i'm not sure that cdrom is D.

How can i dinamycally search the image to apply?!

Link to comment
Share on other sites

This the cmd file that I use, I call this from a menu.... that is loaded during the loading of vistape (Winpe 2)

This allows me then to choose which image i wish to install on the PC that I am working on... That way you still have control..

@echo off

cd /d %~dp0

set imgx=%cd%

if not exist "%cd%\imagex.exe" goto _notexist

goto _main

:_notexist

echo.

echo IMAGEX.EXE executable not found. Please ensure that IMAGEX_APPLY.CMD

echo is in the same folder as IMAGEX.EXE before executing this script.

echo This script will now exit.

echo.

pause

exit

:_main

echo.

echo.

echo.

echo [i M A G E X A P P L Y M A I N M E N U]

echo.

echo 1) Specify or change source path (the path to you .wim image file)

echo Source: [%_asource%]

echo.

echo 2) Specify or change target path, where your image will be restored

echo Target: [%_atarget%]

echo.

echo 3) Specify or change index you want to restore (a number, such as 2)

echo Index: [%_index%]

echo.

if "%_asource%" == "" goto _menu1

if "%_atarget%" == "" goto _menu1

if "%_index%" == "" goto _menu1

echo 4) Apply your image now where ready

echo From [%_asource%] To [%_atarget%]

echo.

:_menu1

echo Q) Quit. R) Reset all variables.

echo.

:_mainch

set _ok=

set /p _ok=Enter your choice:

if "%_ok%" == "1" goto _getsrc

if "%_ok%" == "2" goto _gettarget

if "%_ok%" == "3" goto _getindex

if "%_ok%" == "4" goto _apply

if /I "%_ok%" == "q" goto _end

if /I "%_ok%" == "r" goto _reset

goto _mainch

:_getsrc

set _ok=

echo.

echo Specify location of source image to restore with full path.

set /p _ok=Enter Source path:

for %%A in (%_ok%) do set _ext=%%~xA

if not exist %_ok% (

echo.

echo ---------------------------------------------------------

echo Path does not exist. Please input a valid location again.

echo ---------------------------------------------------------

goto _getsrc

) else (

if /I "%_ext%"==".wim" (

set _asource=%_ok%

setx _asource %_ok%

goto _main

) else (

echo.

echo ---------------------------------------------------------------

echo Error: The path "%_ok%" does not seem to be a valid .wim image file.

echo ---------------------------------------------------------------

goto _getsrc

pause

)

)

:_gettarget

set _ok=

echo.

echo Specify target to install source image with full path.

set /p _ok=Enter Target path:

if exist "%_ok%" (

set _atarget=%_ok%

setx _atarget %_ok%

) else (

echo.

echo ---------------------------------------------------------------

echo Error: The path "%_ok%" is not a correct location.

echo ---------------------------------------------------------------

goto _gettarget

pause

)

goto _main

:_getindex

set _ok=

echo.

echo Specify image index with number

set /p _ok=Enter Index number:

set _index=%_ok%

setx _index %_ok%

goto _main

:_apply

echo.

echo.

"%imgx%\imagex.exe" /apply "%_asource%" %_index% "%_atarget%"

echo.

pause

goto _end

:_reset

set _asource=

set _index=

set _atarget=

goto _main

:_end

Edited by ner
Link to comment
Share on other sites

Thanks ner for this usefull script, but i'm looking for a solution without asking to final user wich is Dvd drive letter (my final users are very stupid).

Edited by eHyde
Link to comment
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.
×
×
  • Create New...