MSFN Forum: WinPe 3.0 startnet.cmd and batch files - MSFN Forum

Jump to content


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

WinPe 3.0 startnet.cmd and batch files WinPe 3.0 immediately reboots when I call a script from startnet.cmd Rate Topic: -----

#1 User is offline   sw2000 

  • Newbie
  • Group: Members
  • Posts: 13
  • Joined: 14-March 08

Posted 12 January 2010 - 01:34 PM

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

This post has been edited by sw2000: 12 January 2010 - 01:40 PM



#2 User is offline   Jazkal 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 592
  • Joined: 16-January 04

Posted 12 January 2010 - 01:37 PM

is the dos window closing right before it reboots?

#3 User is offline   sw2000 

  • Newbie
  • Group: Members
  • Posts: 13
  • Joined: 14-March 08

Posted 12 January 2010 - 01:42 PM

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?

View PostJazkal, on Jan 12 2010, 01:37 PM, said:

is the dos window closing right before it reboots?

This post has been edited by sw2000: 12 January 2010 - 01:43 PM


#4 User is offline   Jazkal 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 592
  • Joined: 16-January 04

Posted 12 January 2010 - 01:53 PM

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.

#5 User is offline   sw2000 

  • Newbie
  • Group: Members
  • Posts: 13
  • Joined: 14-March 08

Posted 12 January 2010 - 01:59 PM

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


View PostJazkal, on Jan 12 2010, 01:53 PM, said:

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.

This post has been edited by sw2000: 12 January 2010 - 02:02 PM


#6 User is offline   sw2000 

  • Newbie
  • Group: Members
  • Posts: 13
  • Joined: 14-March 08

Posted 12 January 2010 - 02:24 PM

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

This post has been edited by sw2000: 12 January 2010 - 02:25 PM


#7 User is offline   Jazkal 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 592
  • Joined: 16-January 04

Posted 12 January 2010 - 03:31 PM

try removing this part:

Quote

goto END
:END


#8 User is offline   sw2000 

  • Newbie
  • Group: Members
  • Posts: 13
  • Joined: 14-March 08

Posted 12 January 2010 - 03:59 PM

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 User is offline   cluberti 

  • Gustatus similis pullus
  • Group: Supervisor
  • Posts: 11,219
  • Joined: 09-September 01
  • OS:Windows RT
  • Country: Country Flag

Posted 12 January 2010 - 04:27 PM

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.

#10 User is offline   sw2000 

  • Newbie
  • Group: Members
  • Posts: 13
  • Joined: 14-March 08

Posted 12 January 2010 - 06:17 PM

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.technet.microsoft.com/Forums...af-c3fd61a0feaf

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

This post has been edited by sw2000: 12 January 2010 - 06:31 PM


#11 User is offline   cluberti 

  • Gustatus similis pullus
  • Group: Supervisor
  • Posts: 11,219
  • Joined: 09-September 01
  • OS:Windows RT
  • Country: Country Flag

Posted 12 January 2010 - 06:35 PM

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.

#12 User is offline   Tripredacus 

  • K-Mart-ian Legend
  • Group: Super Moderator
  • Posts: 8,726
  • Joined: 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Posted 13 January 2010 - 08:35 AM

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.

#13 User is offline   sw2000 

  • Newbie
  • Group: Members
  • Posts: 13
  • Joined: 14-March 08

Posted 13 January 2010 - 08:47 AM

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 User is offline   cluberti 

  • Gustatus similis pullus
  • Group: Supervisor
  • Posts: 11,219
  • Joined: 09-September 01
  • OS:Windows RT
  • Country: Country Flag

Posted 13 January 2010 - 09:40 AM

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.

#15 User is offline   Eagle710 

  • Member
  • PipPip
  • Group: Members
  • Posts: 159
  • Joined: 06-November 08

Posted 31 January 2010 - 12:11 PM

View Postcluberti, on Jan 12 2010, 05:27 PM, said:

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+?

This post has been edited by Eagle710: 31 January 2010 - 12:11 PM


#16 User is offline   cluberti 

  • Gustatus similis pullus
  • Group: Supervisor
  • Posts: 11,219
  • Joined: 09-September 01
  • OS:Windows RT
  • Country: Country Flag

Posted 01 February 2010 - 08:45 AM

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! :)

#17 User is offline   poppyq 

  • Newbie
  • Group: Members
  • Posts: 30
  • Joined: 31-May 04
  • OS:none specified
  • Country: Country Flag

Posted 26 February 2013 - 09:10 AM

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.

Share this topic:


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

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



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