sw2000 Posted January 12, 2010 Posted January 12, 2010 (edited) HelloSince 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)wpeinitcall mstart.batstartnet.cmd (2)wpeinitmstart.batstartnet.cmd (3)wpeinit@echo offclsGoto Begin:BeginECHO FINDING BOOTABLE DRIVEFOR %%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.batgoto END:ENDDoes 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 January 12, 2010 by sw2000
Jazkal Posted January 12, 2010 Posted January 12, 2010 is the dos window closing right before it reboots?
sw2000 Posted January 12, 2010 Author Posted January 12, 2010 (edited) 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 January 12, 2010 by sw2000
Jazkal Posted January 12, 2010 Posted January 12, 2010 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.
sw2000 Posted January 12, 2010 Author Posted January 12, 2010 (edited) 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.loghiberfil.syspagefile.sys"System Volume Information"RECYCLERWindows\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 January 12, 2010 by sw2000
sw2000 Posted January 12, 2010 Author Posted January 12, 2010 (edited) 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? @echo offclsGoto Begin:BeginECHO FINDING BOOTABLE DRIVEFOR %%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.batgoto END:END Edited January 12, 2010 by sw2000
sw2000 Posted January 12, 2010 Author Posted January 12, 2010 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.
cluberti Posted January 12, 2010 Posted January 12, 2010 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.
sw2000 Posted January 13, 2010 Author Posted January 13, 2010 (edited) 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 offclsGoto Begin:BeginECHO FINDING BOOTABLE DRIVEFOR %%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.batgoto END:ENDOn 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-c3fd61a0feafDo you think choice.exe might be causing the problem? Edited January 13, 2010 by sw2000
cluberti Posted January 13, 2010 Posted January 13, 2010 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.DriveNextI 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.
Tripredacus Posted January 13, 2010 Posted January 13, 2010 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.
sw2000 Posted January 13, 2010 Author Posted January 13, 2010 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.DriveNextThanks again!
cluberti Posted January 13, 2010 Posted January 13, 2010 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.
Eagle710 Posted January 31, 2010 Posted January 31, 2010 (edited) 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 January 31, 2010 by Eagle710
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now