• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
sw2000

WinPe 3.0 startnet.cmd and batch files

17 posts in this topic

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
0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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?

Edited by sw2000
0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.