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



Photo

WinPe 3.0 startnet.cmd and batch files

- - - - -

  • Please log in to reply
16 replies to this topic

#1
sw2000

sw2000

    Newbie

  • Member
  • 13 posts
  • Joined 14-March 08
Hello

Since I upgraded to WinPe 3.0 I have not been able to successfully use startnet.cmd to call a batch file on boot up to identify my drive letter. The small DOS like box comes up as usual and you see it runs my batch file and then it immediately reboots WinPe. This process worked fine under WinPE 2.0 and 2.1. Below are variations I have tried in my Startnet.cmd file

startnet.cmd (1)

wpeinit
call mstart.bat


startnet.cmd (2)

wpeinit
mstart.bat

startnet.cmd (3)

wpeinit
@echo off
cls
Goto Begin
:Begin
ECHO FINDING BOOTABLE DRIVE
FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\WinPE_Boot_Media.txt SET DRIVE=%%i:
%DRIVE%\menu.bat
goto END
:END

Does anyone know why or what is causing WinPe to reboot after I call a batch file or running a script from Startnet.cmd. I am completely stumped ?!?!?!?!?!?!

Thank you

Edited by sw2000, 12 January 2010 - 01:40 PM.



How to remove advertisement from MSFN

#2
Jazkal

Jazkal

    Senior Member

  • Member
  • PipPipPipPip
  • 595 posts
  • Joined 16-January 04
is the dos window closing right before it reboots?
Did you RTFM?

#3
sw2000

sw2000

    Newbie

  • Member
  • 13 posts
  • Joined 14-March 08
I believe it does. WinPe 3.0 works perfectly until I add the call batch file or script. It has to be my mistake. Any ideas?

is the dos window closing right before it reboots?


Edited by sw2000, 12 January 2010 - 01:43 PM.


#4
Jazkal

Jazkal

    Senior Member

  • Member
  • PipPipPipPip
  • 595 posts
  • Joined 16-January 04
Sounds like the bat file is closing the startnet.cmd dos window (which would cause a reboot), but your mstart.bat code as listed, shouldn't be doing that.
Did you RTFM?

#5
sw2000

sw2000

    Newbie

  • Member
  • 13 posts
  • Joined 14-March 08
Yes the code posted above is the code I use. I have also rebuildt my WinPe 3.0 and gotten the same results. It comes up, the code runs very quickly, and it reboots. I also include a modified Wimscript.ini and of course ImageX.exe. There nothing special about my boot.wim.


Wimscript.ini

[ExclusionList]
ntfs.log
hiberfil.sys
pagefile.sys
"System Volume Information"
RECYCLER
Windows\CSC
[CompressionExclusionList]
*.mp3
*.zip
*.cab
\WINDOWS\inf\*.pnf


Sounds like the bat file is closing the startnet.cmd dos window (which would cause a reboot), but your mstart.bat code as listed, shouldn't be doing that.


Edited by sw2000, 12 January 2010 - 02:02 PM.


#6
sw2000

sw2000

    Newbie

  • Member
  • 13 posts
  • Joined 14-March 08
I removed all scripting from the startnet.cmd and let WinPe boot up normally. At the X: prompt I typed mstart.bat (my batch file) and it ran and rebooted.

What in the batch file causes this? :realmad:

@echo off
cls
Goto Begin
:Begin
ECHO FINDING BOOTABLE DRIVE
FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\WinPE_Boot_Media.txt SET DRIVE=%%i:
%DRIVE%\menu.bat
goto END
:END

Edited by sw2000, 12 January 2010 - 02:25 PM.


#7
Jazkal

Jazkal

    Senior Member

  • Member
  • PipPipPipPip
  • 595 posts
  • Joined 16-January 04
try removing this part:

goto END
:END


Did you RTFM?

#8
sw2000

sw2000

    Newbie

  • Member
  • 13 posts
  • Joined 14-March 08
Just tried it and the results are the same. I see may boot menu on the USB drive (which is what I want) for just a few seconds and then the reboot.

#9
cluberti

cluberti

    Gustatus similis pullus

  • Supervisor
  • 11,252 posts
  • Joined 09-September 01
  • OS:Windows 8.1 x64
  • Country: Country Flag
Question - what does menu.bat or mstart.bat do? It's the only common denominator here, and you've not included it in your list of things that run yet. I'm betting the problem is in there, not in what you've put in startnet. Also, rename them to .cmd rather than .bat - there's a small difference in that a .cmd doesn't load up the 16bit interpreter (command.com), whereas .bat does. You'll note that startnet.cmd for example is a cmd, not a .bat. It's not what's causing it, but you should be running .cmd's in WinPE, not .bat's.
MCTS Windows Internals, MCITP Server 2008 EA, MCTS MDT/BDD, MCSE/MCSA Server 2003, Server 2012, Windows 8
--------------------
Please read the rules before posting!
Please consider donating to MSFN to keep it up and running!

#10
sw2000

sw2000

    Newbie

  • Member
  • 13 posts
  • Joined 14-March 08
Here is a quick overview: I wanted Mstart.bat to run the script below and identify the drive letter that my USB device was running from and pass that value to %DRIVE% and automatically launch my main menu (menu.bat) on the USB drive. The drive letter varies from machine to machine and I wanted a semi automated process.

mstart.bat

@echo off
cls
Goto Begin
:Begin
ECHO FINDING BOOTABLE DRIVE
FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\WinPE_Boot_Media.txt SET DRIVE=%%i:
%DRIVE%\menu.bat
goto END
:END

On your advise I cleaned up the code a little on my menu.bat. Now when I attempt boot WinPE I do not get the immediate reboot. The main menu ( menu.bat ) stays up but the screen shakes and I have the following error message " 'choice' is not recognized as an internal or external command, operable program or batch file". I do use choice.exe for some prompts on my main menu.bat.

This thread hints at my problem but no resolution.
http://social.techne...af-c3fd61a0feaf

Do you think choice.exe might be causing the problem?

Edited by sw2000, 12 January 2010 - 06:31 PM.


#11
cluberti

cluberti

    Gustatus similis pullus

  • Supervisor
  • 11,252 posts
  • Joined 09-September 01
  • OS:Windows 8.1 x64
  • Country: Country Flag
choice.exe does not exist by default in WinPE 3.0 - you would have had to have copied it into your .wim file offline to use it. Remember, choice.exe is from DOS, as is the command.com interpreter.

You might want to consider vbscript or an HTA rather than a CMD in your WinPE environment, as getting information out of WMI on WinPE is much easier than using a batch:

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
	"SELECT * FROM Win32_CDROMDrive",,48) 
For Each objItem in colItems 
	Wscript.Echo "CD Drive: " & objItem.Drive
Next

I know vbscript is more "code-like", even though it's just a scripting language, but it's tons more powerful, and can have HTA (HTml Application) front-ends for it too. Worth considering, if you're gonna do a lot of work inside WinPE.
MCTS Windows Internals, MCITP Server 2008 EA, MCTS MDT/BDD, MCSE/MCSA Server 2003, Server 2012, Windows 8
--------------------
Please read the rules before posting!
Please consider donating to MSFN to keep it up and running!

#12
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,970 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

I've got the answer for your question. The PE is restarting because of how the startnet.cmd (and the winpeshl.ini for that matter) operates. Whether your script executes or not, we won't know because it exits after running. Since the PE has no further commands to run, it reboots which is its normal behaviour.

You need to launch something to keep the PE open. Easiest may be a program or HTA that has a button that runs your script. That way, when the script is finished, the thing you launched it from is still open.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
tpxmsfn1_zps393339c1.jpg

#13
sw2000

sw2000

    Newbie

  • Member
  • 13 posts
  • Joined 14-March 08
Thanks everyone for the responses. Its appreciated.

As it turns out not having choice.exe in the WinPE boot.wim (x:system32) was causing me the trouble. Once I added it my boot process fired right up.

Cluberti, I will try your code. I'm always looking to learn a new trick. I'm just curious.... was choice.exe included in WinPe 2.1 and I forgot I added it when I built the .wim or was it just omitted on WinPe 3.0?

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_CDROMDrive",,48)
For Each objItem in colItems
Wscript.Echo "CD Drive: " & objItem.Drive
Next

Thanks again! :thumbup

#14
cluberti

cluberti

    Gustatus similis pullus

  • Supervisor
  • 11,252 posts
  • Joined 09-September 01
  • OS:Windows 8.1 x64
  • Country: Country Flag
I honestly don't remember if it was included in PE 2.x, but it could have been. I don't have one around to test at the moment, so my answer is going to be "I don't know". I do know for sure it isn't included in WinPE 3.x.
MCTS Windows Internals, MCITP Server 2008 EA, MCTS MDT/BDD, MCSE/MCSA Server 2003, Server 2012, Windows 8
--------------------
Please read the rules before posting!
Please consider donating to MSFN to keep it up and running!

#15
Eagle710

Eagle710

    Member

  • Member
  • PipPip
  • 159 posts
  • Joined 06-November 08

Question - what does menu.bat or mstart.bat do? It's the only common denominator here, and you've not included it in your list of things that run yet. I'm betting the problem is in there, not in what you've put in startnet. Also, rename them to .cmd rather than .bat - there's a small difference in that a .cmd doesn't load up the 16bit interpreter (command.com), whereas .bat does. You'll note that startnet.cmd for example is a cmd, not a .bat. It's not what's causing it, but you should be running .cmd's in WinPE, not .bat's.


So it is recommened to use CMD and not BAT files in WinPE 2.0+?

Edited by Eagle710, 31 January 2010 - 12:11 PM.

Flying High

#16
cluberti

cluberti

    Gustatus similis pullus

  • Supervisor
  • 11,252 posts
  • Joined 09-September 01
  • OS:Windows 8.1 x64
  • Country: Country Flag
It's been recommended to use .cmd files since Windows NT - only use a .bat file if you actually *need* the 16bit command.com interpreter. I cannot think of many scenarios nowadays where a script would need access to the 16bit interpreter (what you have posted here certainly does not), as the 32bit cmd.exe does pretty much everything you should need - since 1993! :)
MCTS Windows Internals, MCITP Server 2008 EA, MCTS MDT/BDD, MCSE/MCSA Server 2003, Server 2012, Windows 8
--------------------
Please read the rules before posting!
Please consider donating to MSFN to keep it up and running!

#17
poppyq

poppyq

    Newbie

  • Member
  • 30 posts
  • Joined 31-May 04
  • OS:none specified
  • Country: Country Flag
Most likely your menu.bat has an exit command or something similar in it, which would cause startnet.cmd to finish. You need startnet to start something else that will "hold" it open, such as a start /w cmd.exe.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users