Start vbscript on windowsPE phase


MichelG

New member
Local time
8:08 PM
Posts
5
Visit site
OS
Windows 10
XML:
                <RunSynchronousCommand wcm:action="add">
                    <Order>21</Order>
                        <Path>cmd.exe /c "start /MIN cscript.exe //E:vbscript E:\removeedge.vbs"</Path>
                </RunSynchronousCommand>
I have created a vbscript into the same root folder of the setup.exe and rebuild the .iso, but when the auto installation start the script doesn't get called.

I test manually calling it from the cmd and it does work, just the auto start not, what im missing?
 

My Computer

System One

  • OS
    Windows 10
    Computer type
    PC/Desktop
XML:
                <RunSynchronousCommand wcm:action="add">
                    <Order>21</Order>
                        <Path>cmd.exe /c "start /MIN cscript.exe //E:vbscript E:\removeedge.vbs"</Path>
                </RunSynchronousCommand>
I have created a vbscript into the same root folder of the setup.exe and rebuild the .iso, but when the auto installation start the script doesn't get called.

I test manually calling it from the cmd and it does work, just the auto start not, what im missing?
1- Wrong forum, your system is listed as Windows 10. Ten Forums - Windows 10 Help and Support Forum
2- No Windows build number is provided.
3- No Specs specified under My Computer.
3- Your VB executable is unpathed in your script. (It works when within Windows but fails within PE)
 
Last edited:

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    Laptop
    Manufacturer/Model
    ASUSTeK COMPUTER INC. TUF Gaming FX705GM
    CPU
    2.20 gigahertz Intel i7-8750H Hyper-threaded 12 cores
    Motherboard
    ASUSTeK COMPUTER INC. FX705GM 1.0
    Memory
    24428 Megabytes
    Graphics Card(s)
    Intel(R) UHD Graphics 630 / NVIDIA GeForce GTX 1060
    Sound Card
    Intel(R) Display Audio / Realtek(R) Audio
    Monitor(s) Displays
    Integrated Monitor (17.3"vis)
    Screen Resolution
    FHD 1920X1080 16:9
    Hard Drives
    2 SSD SATA/NVM Express 1.3
    WDS500G2B0A-00SM50 500.1 GB
    WDCSDAPNUW-1002 256 GB
    PSU
    19V DC 6.32 A 120 W
    Cooling
    Dual Fans
    Mouse
    MS Bluetooth
    Internet Speed
    Fiber 1GB Cox -us & 400MB Orange-fr
    Browser
    Edge Canary- Firefox Nightly-Chrome Dev
    Antivirus
    Windows Defender
    Other Info
    VMs of Windows 11 stable/Beta/Dev/Canary
    VM of XeroLinux- Arch based & Debian 12
  • Operating System
    Windows 11 Insider Canary
    Computer type
    Laptop
    Manufacturer/Model
    ASUS X751BP
    CPU
    AMD Dual Core A6-9220
    Motherboard
    ASUS
    Memory
    8 GB
    Graphics card(s)
    AMD Radeon R5 M420
    Sound Card
    Realtek
    Monitor(s) Displays
    17.3
    Screen Resolution
    1600X900 16:9
    Hard Drives
    1TB 5400RPM

My Computer

System One

  • OS
    Windows 11 Home
    Computer type
    PC/Desktop
    CPU
    AMD Ryzen 5 8600G (07/24)
    Motherboard
    ASROCK B650M-HDV/M.2 3.15 (07/24)
    Memory
    2x32GB Kingston FURY DDR5 5600 MHz CL36 @4800 CL40 (07/24)
    Graphics Card(s)
    ASROCK Radeon RX 6600 Challenger D 8G @60FPS (08/24)
    Sound Card
    Creative Sound BlasterX AE-5 Plus (05/24)
    Monitor(s) Displays
    24" Philips 24M1N3200ZS/00 (05/24)
    Screen Resolution
    1920×1080@165Hz via DP1.4
    Hard Drives
    Kingston KC3000 NVMe 2TB (05/24)
    ADATA XPG GAMMIX S11 Pro 512GB (07/19)
    PSU
    Seasonic Core GM 550 Gold (04/24)
    Case
    Fractal Design Define 7 Mini with 3x Noctua NF-P14s/12@555rpm (04/24)
    Cooling
    Noctua NH-U12S with Noctua NF-P12 (04/24)
    Keyboard
    HP Pavilion Wired Keyboard 300 (07/24) + Rabalux 76017 Parker (01/24)
    Mouse
    Logitech M330 Silent Plus (04/23)
    Internet Speed
    500/100 Mbps via RouterOS (05/21) & TCP Optimizer
    Browser
    Edge & Brave for YouTube & LibreWolf for FB
    Antivirus
    NextDNS
    Other Info
    Backup: Hasleo Backup Suite (PreOS)
    Headphones: Sennheiser RS170 (09/10)
    Phone: Samsung Galaxy Xcover 7 (02/24)
    Chair: Huzaro Force 4.4 Grey Mesh (05/24)
    Notifier: Xiaomi Mi Band 9 Milanese (10/24)
    2nd Monitor: AOC G2460VQ6 @75Hz (02/19)
Windows 11 24H2 - VBSCRIPT Disabled

And how would you automatize anything during windowsPe phase if theres no powershell at that point.
 

My Computer

System One

  • OS
    Windows 10
    Computer type
    PC/Desktop
1- Wrong forum, your system is listed as Windows 10. Ten Forums - Windows 10 Help and Support Forum
2- No Windows build number is provided.
3- No Specs specified under My Computer.
3- Your VB executable is unpathed in your script. (It works when within Windows but fails within PE)
Sorry, ill provide more details.

I'm installing the Windows OS on a VMWare Workstation environment, my question applies both for Win10/Win11 (im working with both)
I'm not sure about the Windows version, its the latest available as today.

I'm trying to figure why the vbscript is not geting called.
I didnt understand what you mean on:
(It works when within Windows but fails within PE)?
The vbscript will run only during the PE phase, but its not being started with the auto installation.
The script is on the same root folder of the setup.exe, running shift+F10 i can find it at E:\ and 'manually' starting it, it does work.
 

My Computer

System One

  • OS
    Windows 10
    Computer type
    PC/Desktop
XML:
                <RunSynchronousCommand wcm:action="add">
                    <Order>21</Order>
                        <Path>cmd.exe /c "start /MIN cscript.exe //E:vbscript E:\removeedge.vbs"</Path>
                </RunSynchronousCommand>
I have created a vbscript into the same root folder of the setup.exe and rebuild the .iso, but when the auto installation start the script doesn't get called.
This command expects to have the media always mounted as drive E:

It might work for your setup, but isn't a portable solution. If the cleanup script is small, then mount boot.wim and copy it into the WinPE image. Commit the changes, and update boot.wim. Now run X:\path\removeedge.vbs to guarantee the script is always found.

Replacing cscript.exe with wscript.exe would eliminate the need to minimize the CMD shell, since wscript doesn't appear onscreen.
Code:
                <RunSynchronousCommand wcm:action="add">
                    <Order>21</Order>
                        <Path>wscript X:\path\removeedge.vbs</Path>
                </RunSynchronousCommand>

VBScript is disabled for normal Windows, but it still works for WinPE since so many folks have legacy install scripts.
 

My Computer

System One

  • OS
    Windows 7
Where the install media source is F:\

Code:
mkdir C:\temp_mount
dism /Mount-Wim /wimfile:F:\sources\boot.wim /Index:2 /MountDir:C:\temp_mount
copy G:\removeedge.vbs C:\temp_mount
dism /Unmount-Wim C:\temp_mount /Commit

boot.wim's filesystem is loaded into RAM disk as X:\, so during run-time it's X:\removeedge.vbs
 

My Computer

System One

  • OS
    Windows 7
  • Like
Reactions: OAT

My Computer

System One

  • OS
    Windows 7
Where the install media source is F:\

Code:
mkdir C:\temp_mount
dism /Mount-Wim /wimfile:F:\sources\boot.wim /Index:2 /MountDir:C:\temp_mount
copy G:\removeedge.vbs C:\temp_mount
dism /Unmount-Wim C:\temp_mount /Commit

boot.wim's filesystem is loaded into RAM disk as X:\, so during run-time it's X:\removeedge.vbs
On my case the files are on E:

1733690042479.webp

I could write the entire script into a RunSynchronousCommand but the text value (i.e. after unescaping the XML markup) of the <Path> element must not exceed 259 characters in length, then i would need to split it into multiple commands, something like:
XML:
<RunSynchronousCommand wcm:action="add">
   <Order>19</Order>
   <Path>cmd.exe /c "&gt;&gt;"X:\removeedge.vbs" (echo ...&amp;echo ...&amp;echo ...&amp;echo ...")"</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
   <Order>20</Order>
   <Path>cmd.exe /c "&gt;&gt;"X:\removeedge.vbs" (echo ...&amp;echo ...&amp;echo ...&amp;echo ...")"</Path>
</RunSynchronousCommand>
... etc ... etc
This is hard to maintain and manage, do you know if there's any other way that i could use to load the entire script at once on this specific phase?

There are optional WinPE add-ons for installing PowerShell and WMI to boot.wim. That's how some IT pro's handle advanced scripting.

Amazing, i have been able to get the vmware tools installed at the specialize phase, clipboard actions like copy/paste from host to the machine starts working but changing the resolution doesn't, i tried printing available resolutions and it still shows only one.

Do you know if there's any "trick" to install the vmware tools at the WinPE phase? when i execute the installer it shows installing but nothing happens.
 
Last edited:

My Computer

System One

  • OS
    Windows 10
    Computer type
    PC/Desktop
1. WinPE (Setup) works by booting up, and extracting boot.wim's files to a RAM disk mounted on X:. It's always drive X. You can put scripts in other locations, but the problem is you need some command to scan through the possible drives to find your script. So the best method is to insert the script directly INSIDE boot.wim. This is done by mounting boot.wim to a temporary folder, copying to it like a normal folder, and permanently writing back the updated folder contents to boot.wim (overwriting it).

2. Trying to do long scripted commands in RunSynchronousCommand is not manageable. Which is why it's preferred to keep them in a self-contained script. Shorter commands (under 259 chars) are fine.

3. You don't install vmware tools in the WinPE phase, because Windows has extracted the install WIM and hasn't rebooted into the 2nd (and later passes) to finish installing Windows. What you should do is install vmware tools during specialize or post-OOBE passes.

Normally you create a new subfolder on the ISO: "\sources\$OEM$\$1\MyFolder" -- where $1 maps to C:\ and C:\MyFolder or any longer path which includes a set of subfolders. During WinPE, Setup will copy everything from "sources\$OEM$" to the install disk, following the folder structure.

When you reach the specialize pass, C:\MyFolder will already exist with whatever files you saved under it. Now unattended is guaranteed to find files in C:\MyFolder since it's now rebooted into full Windows and doesn't need the install media.
Code:
    <settings pass="specialize">
        <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Path>C:\MyFolder\setup64.exe /s /v&quot;/qn REBOOT=R&quot;</Path>
                    <Order>1</Order>
                </RunSynchronousCommand>
            </RunSynchronous>
        </component>
    </settings>
 

My Computer

System One

  • OS
    Windows 7

Latest Support Threads

Back
Top Bottom