6 Replies Latest reply on May 13, 2010 2:27 AM by phoffmann

    WinPE and DOS generic task scripts

    DesktopAdmin Rookie

      Is there a way to create a command line script to run within the WinPE LANDesk pxemenu?

      Here is what I want to do.  I want to have WinPE 32-bit be able to install Windows 7 64-bit to computers.  I can do this fine in the Command Shell in WinPE manually.  I want to get away from the manual process and have an item in the pxemenu that I click on and it automates the commands.  I thought creating a  "New DOS generic task script" and then adding it to the pxemenu would work. However, everytime I click on it the pxemenu disappears and nothing happens.  Here is the commands I am trying to automate.

       

      net use j: \\corprt1\images\windows_7\64-bit /user:ldmssvc ******
      net use k: \\corprt1\images\windows_7\32-bit /user:ldmssvc ******
      k:\setup.exe /installfrom:j:\sources\install.wim

        • 1. Re: WinPE and DOS generic task scripts
          DesktopAdmin Rookie

          I got this to work using a Provisioning Template.  I still would like to know if DOS generic task scripts can work in the LANDesk PXE Boot Menu while in WinPE.

          • 2. Re: WinPE and DOS generic task scripts
            phoffmann SupportEmployee

            "Sort of".

             

            So - a "DOS generic script" will NOT work, since the OS is set to be DOS, and that's it.

             

            However, you COULD create a WinPE OSD task, and then just take an axe to the INI-script file and write up your own scripted commands via the "advanced edit" option. It'd need to "start life out" as a WinPE script, but then you can use the advanced edit to change everything.

             

            You can have it then run the relevant commands and so on, via REMEXEC - I'm assuming you're familiar with how to write your own LD-custom script, effectively?

             

            If my assumption is wrong, please say so and I'll see what I can do to try and help you out a bit.

             

            - Paul Hoffmann

            LANDesk EMEA Technical Lead

            • 3. Re: WinPE and DOS generic task scripts
              DesktopAdmin Rookie

              I'm not really familiar writing LD-custom scripts.  Can you give me an example how I could incorporate the commands above into a LD script?

              • 4. Re: WinPE and DOS generic task scripts
                phoffmann SupportEmployee

                I'll try to get to this during the later part of the week - this will be a bit of a longer explanation to write up, but the "doing" itself isn't that complicated.

                 

                I just try to explain things in context, so that it's not just "monkey see - monkey do", but so that you actually stand a good chance at understanding what you're doing and why, and thus - how you can use similiar tricks to make your life easier in the future.

                 

                - Paul Hoffmann

                LANDesk EMEA Technical Lead

                1 of 1 people found this helpful
                • 5. Re: WinPE and DOS generic task scripts
                  DesktopAdmin Rookie

                  Thanks Paul.  Much appreciated.

                  • 6. Re: WinPE and DOS generic task scripts
                    phoffmann SupportEmployee

                    1 - So - to begin with you'll need a WinPE OSD script. Any old script will do, I've created a "capture image" script for reference.

                     

                    I would suggest using the account / password you want to authenticate to your NET USE with here as well. In this case, I'm using "Malfeas\administrator" and a password of "pw" (you won't see "pw" - you'll only see its hashed equivalent). That way you've not got any clear-text passwords.

                     

                    [VALUES]
                    Task=7
                    ScriptName=My OSD Image Capture
                    ScriptDescription=My OSD Image Capture
                    FallBackNIC=
                    UseFallBackNIC=FALSE
                    ImageUserName=administrator
                    ImageDomain=malfeas
                    ImagePassword=102F12858EEB77577E04F627A3B

                    ImageToolType=5
                    ImageUNC=\\malfeas\ldmain\landesk\files
                    ToolUNC=\\malfeas\ldmain\osd\imagew 2\imagew.exe
                    ImageToolCmd=RunBatch -1 H:\osd\IMAGEW~1 backall.bat 0 i:\landesk\files\%Computer - Device Name{6}%, STATUS FACILITY=3510, SYNC
                    [OWNER]
                    GUID=f0e5b79d-2f17-4aeb-a884-fbda21443929
                    OSDPLUG=TRUE
                    DESCRIPTION=My OSD Image Capture
                    NAME=My OSD Image Capture
                    TYPE=WinPE
                    [JOBPARAM]
                    ABORT_ON_CMD_FAILURE=1
                    TASK_COMPLETION_ENABLED=FALSE
                    [MACHINES]
                    REMEXEC0=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/bootfile.exe"
                    REMEXEC1=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/tlibr16.dll"
                    REMEXEC2=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/tlibr32.dll"
                    REMEXEC3=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/lddefrag.exe"
                    REMEXEC4=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/FlushBuffer.exe"
                    REMEXEC5=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/cicfgmgr.vxd"
                    REMEXEC6=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/cindis.vxd"
                    REMEXEC7=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/copyfile.exe"
                    REMEXEC8=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/boot.img"
                    REMEXEC9=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/ChangeBCD.exe"
                    REMEXEC10=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/vboot/BCD"
                    REMEXEC11=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /p="http://%CUSTJOBHOSTIP%/landesk/files/bcdedit.exe"
                    REMEXEC12=<qt/>%LDMS_CLIENT_DIR%\ChangeBCD<qt/> <qt/>%LDMS_CLIENT_DIR%\bcdedit.exe<qt/> <qt/>%LDMS_CLIENT_DIR%\BCD<qt/>
                    REMEXEC13=<qt/>%LDMS_CLIENT_DIR%\sdclient.exe<qt/> /f /o /dest="C:\boot.wim" /p="http://%CUSTJOBHOSTIP%/landesk/vboot/boot.wim"
                    REMEXEC14=<qt/>%LDMS_CLIENT_DIR%\copyfile.exe<qt/> <qt/>%LDMS_CLIENT_DIR%\boot.img<qt/> <qt/>%LDMS_CLIENT_DIR%\BCD<qt/> \boot\BCD
                    REMEXEC15=<qt/>%LDMS_CLIENT_DIR%\lddefrag.exe<qt/> <qt/>%LDMS_CLIENT_DIR%\boot.img<qt/>, STATUS
                    REMEXEC16=<qt/>%LDMS_CLIENT_DIR%\FlushBuffer.exe<qt/>, STATUS
                    REMEXEC17=<qt/>%LDMS_CLIENT_DIR%\bootfile.exe<qt/> %LDMS_CLIENT_DIR%\boot.img /keep /bootunsafe, ASYNC
                    BEGINWINPE=TRUE
                    REMPING18=WINPE, TIMEOUT=1800

                    REMEXEC19=diskpart /s X:\LDClient\rmvol.txt
                    REMEXEC20=drvmap.exe malfeas\administrator 102F12858EEB77577E04F627A3B I: <qt/>\\malfeas\ldlogon<qt/>, STATUS FACILITY=3513
                    REMEXEC21=drvmap.exe malfeas\administrator 102F12858EEB77577E04F627A3B H: <qt/>\\malfeas\ldmain<qt/>, STATUS FACILITY=3513

                    REMEXEC22=diskpart /s X:\LDClient\assvol.txt
                    REMEXEC23=cmd /c del /f /q C:\boot.wim
                    REMEXEC24=ldrun RunBatch -1 H:\osd\IMAGEW~1 backall.bat 0 i:\MyImageDir\%Computer - Device Name{6}%, STATUS FACILITY=3510, SYNC, TIMEOUT=3600
                    REMEXEC25=ldrun reboot, timeout=2

                     

                    Here's the important stuff:

                    - The stuff I marked in BOLD RED == after this part, the WinPE section starts.

                    - The stuff I marked in BOLD BLUE == this is where the (default) drive mappings take place.

                     

                    =========

                     

                    2 - If you only need to map two network drives, then I suggest you "abuse" the wizard, and have one be the server where you 'store' the image, and the other where the imaging utility is, as it were (this will sort out most of the syntax for you).

                     

                    I prefer not to use NET USE, as it's pretty much nonexistant in regards to security.

                     

                    The only "gotcha" is that - if you look closely - by default our DRVMAP commands only map to "\\server\Mainsharename" and no subdirectories.

                     

                    So if you have - say "\\MyServer\MyShare\MyInterestingDirectory\" then we will map a drive only to "\\MyServer\MyShare\" and you'd need to access "MyInterestingDirectory" by using the drive-letter (say I:\ for instance) by hitting up "I:\MyInterestingDirectory\").

                     

                    You can fiddle a bit around with this as you want .

                     

                    =============

                     

                    3 - Now - the stuff we're "really" interested in is only the stuff after the two lines I marked in red. Everything before that is "in case the device is in Windows", where we'd copy down a virtual boot image and then reboot the device. The real action takes place after the "REMPING..." command.


                    IMPORTANT NOTE ==> notice that each line has a unique number after the REMEXEC command. This is IMPORTANT to keep in mind (and continue to do), or else CUSTJOB will break when processing the script. Now, the numbers DON'T have to be sequential - CUSTJOB will work down the script from "top to bottom", but the numbers DO have to be unique.

                     

                    So this is OK:

                    REMEXEC12=...

                    REMEXEC100=Stuff I wanted to insert in the middle.

                    REMEXEC200=More Stuff I wanted to insert in the  middle

                    REMEXEC13=...

                    REMEXEC14=...

                     

                    while this is NOT OK

                    REMEXEC12=...

                    REMEXEC12=I forgot to change the number

                    REMEXEC12=I forgot to change the number

                    REMEXEC13=...

                    REMEXEC14=...

                     

                    REMEXEC stands for "remote execute", in case you wondered.

                     

                    ==============

                     

                    4 - Now, MOST commands are simple enough to do, and follow this format:

                    ""

                    REMEXEC(somenumber) = (the command-line you'd normally run)

                    ""

                     

                    So a "simple" custom script / OSD-scrupt example would be:

                    [MACHINES]

                    REMEXEC01=notepad.exe

                     

                    the "[MACHINES]" part is to make sure that "all OS's" run these commands, as opposed to - say - [MACHINES_NT] (which is only NT-based OS'es) or [MACHINE_95] (Windows 95/98 clients).

                     

                    =================

                     

                    5 - Now, the above example also has another interesting gotcha.


                    CUSTJOB will WAIT (!) for a command line to finish. In the case of "NOTEPAD.EXE" this means that notepad needs to be closed to "finish". this may NOT be what you're after - for that you can add ", ASYNC" at the end of the line (essentially telling it "start this, and then go on straight to the next command - don't wait for this to exit".

                     

                    So we'd have:

                    [MACHINES]

                    REMEXEC01=notepad.exe, ASYNC

                     

                     

                    =================

                     

                    6 - there's also some things - notably calling batch files - where "just using the command-line" is not enough (batch files need to be called), and you may need to have a "more real" command line interpreter.

                     

                    For those we have the option of using "cmd /c (command line) - such as we do in our default generated script. Let me highlight it for you:

                    ....
                    BEGINWINPE=TRUE
                    REMPING18=WINPE, TIMEOUT=1800
                    REMEXEC19=diskpart /s X:\LDClient\rmvol.txt
                    REMEXEC20=drvmap.exe malfeas\administrator 102F12858EEB77577E04F627A3B I: <qt/>\\malfeas\ldmain<qt/>, STATUS FACILITY=3513
                    REMEXEC21=drvmap.exe malfeas\administrator 102F12858EEB77577E04F627A3B H: <qt/>\\malfeas\ldmain<qt/>, STATUS FACILITY=3513
                    REMEXEC22=diskpart /s X:\LDClient\assvol.txt
                    REMEXEC23=cmd /c del /f /q C:\boot.wim
                    REMEXEC24=ldrun RunBatch -1 H:\osd\IMAGEW~1 backall.bat 0 i:\landesk\files\%Computer - Device Name{6}%, STATUS FACILITY=3510, SYNC, TIMEOUT=3600
                    REMEXEC25=ldrun reboot, timeout=2

                     

                    ===============

                     

                    That should help you out a fair bit. Essentially, you start by creating a default OSD script, and then you right-click on it, selecting the "ADVANCED EDIT" option (make a backup copy), and then playing with it as you need.

                     

                    Even though it may have started life out as an OSD task, you can repurpose it quite happily.

                     

                    I hope that gives you what you need?

                     

                    - Paul Hoffmann

                    LANDesk EMEA Technical Lead