[HELP] Convert cmd script to Powershell

Discussion in 'Scripting' started by ashish.k, Dec 4, 2015.

  1. ashish.k

    ashish.k MDL Senior Member

    Dec 27, 2014
    299
    134
    10
    Hi All,
    I need help for converting this setupcomplete.cmd and install.cmd scripts to Powershell.

    Please help.

    View attachment Scripts.txt
     
  2. Smorgan

    Smorgan Glitcher

    Mar 25, 2010
    1,855
    1,051
    60
    #2 Smorgan, Dec 4, 2015
    Last edited by a moderator: Apr 20, 2017
    Well first your code is kinda bad. Why are you using a for loop to find the drive? I mean we already know that the WIM has expanded the installation media to the install drive so only:

    Code:
    pushd %~dp0
    
    or 
    
    cd %windir%\Setup\Scripts
    
    Is really necessary.

    However lets get started first you need a cmd controller for powershell. If we did a pure code conversion there would be no way for the SetupComplete.ps1 to run and its best to not mix coding languages.

    SetupComplete.cmd

    Code:
    pushd %~dp0
    regedit /s "UAC.reg"
    
    echo Execute Powershell Setup
    PowerShell -WindowStyle Hidden -ExecutionPolicy Bypass -NoProfile -File "Setup.ps1"
    
    Now moving on we at a minimum need a SetupComplete.cmd this will intialize our powershell stuff.

    Setup.ps1

    Code:
    # For Dism install
    Dism /online /enable-feature /featurename:NetFx3 /All 
    
    # For the Better install use the dotnet full 4
    start-process "dotNetFx40_Full_x86_x64.exe" -ArgumentList "/q /norestart" -wait
    start-process "KMSpico.exe" -ArgumentList "/verysilent" -Wait
    
    Additionally this is a dummy script so you don't take advantage of powershell at all. To be honest.
     
  3. ashish.k

    ashish.k MDL Senior Member

    Dec 27, 2014
    299
    134
    10
    Thank you very much! :worthy: