Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
zbarre

Script startup BartPE

Recommended Posts

Hello,

Is it possible to execute a .cmd script at the end of the startup of BartPE ?

If yes how can i do ?

Thanks for your help

Share this post


Link to post
Share on other sites

I beleive you need to edit the winbom.ini file to start your CMD.

Bart did have a plugin to start the network automactically maybe you can use this to run your batch etc.

I am not sure about HTA support on Barts PE.

I have only had experince with WinPE.

Hope that helps if not try Barts Site.

Share this post


Link to post
Share on other sites

zbarre wrote> Is it possible to execute a .cmd script at the end of the startup of BartPE ?

Yes it is I use BartPE from Server2003/RIS via PXE boot from server class machines. All I do is press F12 and I have the RIS .OSC screens fully automated to automatically login to RIS and run only BartPE (do you need anything more?)

Check the following plugin directory: pebuilder3110a\plugin\penetcfg and look for the penetcfg.ini You can edit this .ini file with your favorite text editor like Notepad. I have bolded the lines that are critical to fully automating Network startup in BartPE and the line you asked for in particular is shown at the bottom of the listing shown below.

pebuilder3110a\plugin\penetcfg\penetcfg.ini

[General]

AutoStartNet=Yes

PromptForProfile=No

ShowGUI=No

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[NetProfiles]

Dynamic IP Address (DHCP)= penetcfg-dhcp.ini

Static IP Address (Manual)= penetcfg-static.ini

Custom from A:\= a:\penetcfg.ini

Custom from C:\= c:\penetcfg.ini

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[NetID]

; ComputerName = CRS-PE

Workgroup = crs.yourdomain.com

PrimaryDNSSuffix = crs.yourdomain.com

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[FileSharing]

StartFileSharingService = No

; AdminAccount = Pierre

; AdminPassword = 123456

; AdminPassword = * (to be prompted for a password)

; AdminPassword = *

; ShareDriveRoots = Yes

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[NetAdapter1]

; SpeedAndDuplex = {10|100|1000},{Half|Full}

SpeedAndDuplex = Default (for default settings)

;SpeedAndDuplex = 1000,Full

EnableDHCP = Yes

UseStaticGateway = No

UseStaticDNS = No

UseStaticWINS = No

;IPAddress = 192.168.75.2,192.168.75.3

;SubnetMask = 255.255.255.0,255.255.255.0

;DefaultGateway = 192.168.75.230

;DNSServer = 192.168.75.200,192.168.75.201,192.168.75.202

;WINSServer = 192.168.75.150

[NetAdapter2]

;SpeedAndDuplex = 1000,Full

EnableDHCP = Yes

UseStaticGateway = No

UseStaticDNS = No

UseStaticWINS = No

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

; You can map up to 10 network drives: [NetDrive1] ... [NetDrive10];

[NetDrive1]

; Drive = x:

; Drive = * (to use the first available drive letter)

Drive = Z:

NetworkPath = \\Server\Path

UserName = Domain\Username

; Password = (leave it empty to be prompted for a password)

Password = Userpassword

[NetDrive2]

;same syntax as NetDrive1 if you want to map more drives

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[PostNetAutoRun]

; StarupFlag = CommandLine

; StartupFlag is a bit field that can take the following values:

; 0 = run hidden and wait (00 00 00 00)

; 1 = run normal and wait (00 00 00 01)

; 2 = run hidden and don't wait (00 00 00 10)

; 3 = run normal and don't wait (00 00 00 11)

3 = z:\scripts\menu.bat

Just to claify there are other Netprofiles like "penetcfg-dhcp.ini" and "penetcfg.static.ini" but BartPE looks at the "penetcfg.ini" first and if you have the AutoStartNet=Yes and PromptForProfile=No and ShowGUI=No then BartPE will not look at the other NetProfiles and will opt to use whatever default settings you have made farther down in the penetcfg.ini file. Make sense? :wacko:

A slick trick is to map a network drive using the NetDrive section then run the .CMD or .BAT file from a the network drive, this makes it real simple and quick to modify the .CMD file and try different options. My current Menu.Bat has options for running Ghost (with switches of my choosing), installing Server2003, using Diskpart to partition RAW disks and assign them the correct drive letters and format them, run McAfee A/V scans, etc. :D

Hope this helps you out... :thumbup

Share this post


Link to post
Share on other sites

Hi Indi,

Thanks for psoting. Can you please show me how to add the .bat script that will start ghost32 automatically right after BartPE bootup and connected to the network share then start the sripts? Thanks.

Share this post


Link to post
Share on other sites

thesimpsons wrote > Thanks for posting. Can you please show me how to add the .bat script that will start ghost32 automatically right after BartPE bootup and connected to the network share then start the sripts? Thanks.

In my original post the NetDrive section of the pebuilder3110a\plugin\penetcfg\penetcfg.ini file is the key to automatically mapping drives. In the NetDrive section, shown below, simply change the NetworkPath and UserName to the correct information for your network. You can also choose the drive letter by modifying the Drive variable.

On my network I have the Z: drive mapped to an NT share and this is where I store and retrieve the Ghost image files and also where I run a custom .BAT file script that has many menu options.

TIP1: .CMD files are the same as .BAT files were in the DOS 6.x days and either file extension creates an executable command line program in XP or Server2003.

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

; You can map up to 10 network drives: [NetDrive1] ... [NetDrive10];

[NetDrive1]

; Drive = x:

; Drive = * (to use the first available drive letter)

Drive = Z:

NetworkPath = \\Server\Path

UserName = Domain\Username

; Password = (leave it empty to be prompted for a password)

Password = Userpassword

[NetDrive2]

;same syntax as NetDrive1 if you want to map more drives

In my original post this .BAT file is called menu.bat and it's stored on a network drive, Z:\Scripts\menu.bat. The menu.bat file is run from the [PostNetAutoRun] section of the pebuilder3110a\plugin\penetcfg\penetcfg.ini file, see example below.

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[PostNetAutoRun]

; StarupFlag = CommandLine

; StartupFlag is a bit field that can take the following values:

; 0 = run hidden and wait (00 00 00 00)

; 1 = run normal and wait (00 00 00 01)

; 2 = run hidden and don't wait (00 00 00 10)

; 3 = run normal and don't wait (00 00 00 11)

3 = z:\scripts\menu.bat;

The menu.bat file just uses standard command line syntax (DOS) which is most likely beyond the scope of any discussion thread posting. This URL may help you with various commands: Microsoft Windows XP - Command-line reference

If you have setup the Ghost8 plugin in BartPE then you can call Ghost32.exe from a .BAT file by creating a file like my menu.bat and add the following line (the Ghost switches -FDSP -CNS -Z2 are optional) then you can put this .BAT file in the shared directory you are mapping too.

z:\scripts\menu.bat

"X:\Programs\ghost8\GHOST32.EXE" -FDSP -CNS -Z2

NOTE1: You could instead add the .BAT file to your BartPE CD and run it from there; however, it's much easier to modify and try different options by storing this file on a network share where you can quickly edit and run it without having to burn a new BartPE CD or modify the BartPE image on the RIS server. :whistle:

TIP2: Ghost supports a large array or command line switches including the ability to fully automate creating and restoring image files (the -clone switch). The best way to learn about the syntax for these switches is to read the Ghost_ref_Guide.pdf particularly Appendix A titled "Command-line switches". If you Google the phrase (or click this link) ghost_ref_guide you will find this .PDF if you don't already have a copy of it.

So reviewing this example the pebuilder3110a\plugin\penetcfg\penetcfg.ini file has the Z: drive mapped in the [NetDrive1] section and the z:\scripts\menu.bat is ran from the [PostNetAutoRun] section automatically after TCP/IP is started up. The menu.bat file contains a line to run the Ghost32.exe app from the BartPE programs area (usually X:\Programs\Ghost8).

I hope this makes sense and answers your question. :D

Share this post


Link to post
Share on other sites

Thank you very much for your post. i was able to amke this stuff works following your post. I have have something else in mind to get these steps automated. What is the best way to script if I have different type of Dell workstations and want to get the disired images based on the type of workstation? Thanks again.

Share this post


Link to post
Share on other sites

thesimpsons wrote> What is the best way to script if I have different type of Dell workstations and want to get the disired images based on the type of workstation? Thanks again.

The only way I know to do this is to create a DOS menu using the Choice.exe command line utility and have one option for each type of workstation you are cloning. Each menu item would then call the appropriate Ghost32 command line that would be pointed to the correct .GHO file for that type of workstation.

Step 1) Edit the Custom.inf file in the pebuilder3110a\plugin\!custom directory adding the following section and line to the end of the file:

[sourceDisksFiles]

choice.exe=2

This will include the Choice.exe program and make it available for use when you rebuild BartPE. This file listens for the choice you make in the menu shown below.

Here is a shortened down version of the Menu.bat file I use. You can see in option 1 I call to another file, diskpart.bat, to handle this partitioning task; however, for option 2 I call Ghost directly. I just did this to keep complex functions like disk partitioning in their own reusable script in case I want to link it to another menu or something in the future.

:MAIN-MENU

CLS

ECHO.

ECHO.Ghost Imaging Menu

ECHO.-----------------------------------------------------

ECHO.

ECHO.1.) DISKPART (Disk0 / C:=32GB / D:=##, NTFS formated)

ECHO.2.) GHOST (-FDSP -FEMAX -CNS -Z2)

ECHO.3.) End Program.

ECHO.

CHOICE /C:123 /M "Enter your choice:" /N

ECHO.

IF ERRORLEVEL 3 GOTO END-OPTION

IF ERRORLEVEL 2 GOTO GHOST-OPTION

IF ERRORLEVEL 1 GOTO DISKPART-OPTION

GOTO MAIN-MENU

:DISKPART-OPTION

CALL diskpart-crs.bat

GOTO MAIN-MENU

:GHOST-OPTION

"X:\programs\ghost8\GHOST32.EXE" -FDSP -CNS -Z2 -FEMAX

GOTO MAIN-MENU

:END-OPTION

CLS

ECHO.

ECHO.Thank You for using the Ghost Imaging Menu!

TIP: You can only have 9 menu items in a single Choice.exe driven DOS menu; however, you can make the main menu call a secondary menu. So for example your first menu might be the hardware vendor like 1.) HP 2.) Dell 3.) AcmePC etc. then each of those would bring up a new menu with options for the specific models like 1.) Optiplex 170 2.) Preceision 360 3.) Latitude D600 etc.

If you want to automatically recognize the type of workstation and have Ghost run without any user input at all I don't have any help for you. I suppose you might be able to write or borrow some type of program that could read information from the BIOS to determine the model and then call the appropriate Ghost command that way, but this is something I have never done. :blushing:

Seems like once I got to the point where I could press F12 to boot into BartPE with a DOS menu and then choose an option or two from a menu and have Ghost automatically restore the image to the computer was simple and quick enough to not justify the hours of programming it would take to do this any other way. I am all for automation so though so if you find a way to fully automate the Ghost restore by hardware brand/model please post it and let us know how you did it. :D

Share this post


Link to post
Share on other sites

Hello Indy,

Thank you very much for your post again. I have learned a lot for your posts. There is actually a method that allow you to detemine they type of system you boot from. Have you ever heard of something called PCIScan? This program will allow you to scan the system and return with the value to detemine the system type. It will look for the vendor name and code. We can create a file with name and code...when pciscan run, it will compare the name and code then return with the system name. From here, the system will display the message like "You are using Dell280" then come up with menu that ask users to select the type of image they want to get...If you like I would love to discuss with you about this...Thanks again.

Share this post


Link to post
Share on other sites

I have never used PCIScan before but I see Bart has a download link for it on this page http://www.nu2.nu/utils/

I tried to run it from XP but I don't think it can read through the HAL layer. If I get time I may try to run this from BartPE and see what it does. :)

Share this post


Link to post
Share on other sites

PCIScan runs under DOS. Well, it will give you some information about the system, but you have to difine the values from another file so that it can give you the system type. It won't scan the hardware level as you indicated. Do you know what command or switch from ghost that will eject the CD after it finsh downloading the image and reboot the system? I know there is a switch that will do the reboot bot not the one that does the reject of the CD.

Share this post


Link to post
Share on other sites

Well if PCIScan only runs from DOS I am not sure if it will run from BartPE or not (we'll just have to test it). I understand you have to do some work to create a system map file to translate the PCI vendor info into a more friendly name like Dell Optiplex GX520 or something...

Regarding the CD Eject method I don't have to do that because I normally PXE boot and run BartPE from the network, but I decided to do a quick search on Google found this utility (ejectcd.exe) http://www.alexnolan.net/software/commandline.htm for ejecting CD's from the Command Line, so I suppose you could add this to your BartPE build, then modify your .BAT file to do the following:

1.) Run Ghost (with command switches for auto-restoring the image you want)

2.) Run the CD Eject utility

3.) Use the Shutdown command (XP/2003 command) to restart the system; shutdown -r -f

You will have to include Shutdown.exe in your BartPE build. One way is by editing pebuilder3110a\plugin\!custom\Custom.inf and add the following line to the [sourceDiskFiles] section we created earlier in this post (to add Choice.exe). What we are doing here is telling BartPE to pull these files out of the I386 directory when PE Builder builds the BartPE files.

[sourceDisksFiles]

choice.exe=2

shutdown.exe=2

I haven't tried this out yet so I will leave the testing to you on this one... :D

Share this post


Link to post
Share on other sites

thesimpsons wrote> What is the best way to script if I have different type of Dell workstations and want to get the disired images based on the type of workstation? Thanks again.

Ok I saw another user post the same question about how to determine the model of computer from the command line so as to be able to automate driver and application installation so I decided to put some effort into it and here is what I came up with... Your going to love this it's too cool! B)

Check my post here http://www.msfn.org/board/index.php?showto...9entry498859]

Edited by indy_dba

Share this post


Link to post
Share on other sites

Hi Indy,

That was an awsome works that you put up there. I will tell you the current environment that I am working in now. We have a QA lab that runs about 1000 Dell machines which has about 10 different models. The challenge is to come up with the ghost system that will allow users to boot with CD (BartPE), determine system type, come up with menu for OS type, from here user will select OS he/she wants and get ghost image. The system will automatically eject CD and reboot once it finished getting the image. We currently have this kind of system running under DOS boot disk combined with Perl script. The problem with DOS is that it takes too long to download the image when running ghost with DOS. With bartPE, I am able to get the image much faster with ghost32. That's the reason why I like to automate the system running with BartPE bootdisk. So far, I am able to make the sytem bootup and autmate all the steps to ghost. From here, I can select ghost images manually, getting the image and reboot the system automatically after the machine finished getting the image. I can't make the machine eject the CD right after it got the image then reboot. I can only either eject the CD or have the system reboot, but I can't do both. Any ideas how to achive this? How about the menu that allow users slect the OS type? Thanks.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...