Run ALL .reg, .ps1, and .bat files in a folder.
Posted: 11 Mar 2020 14:21
I have a folder with .reg, .ps1, and .bat files [about 80 files in total].
I am trying to put together a Batch Script to run ALL of the files one after the other in SILENT mode within the Implement Folder.
I have created a Batch Script for each . . .
Can anyone see if there is anything wrong with the code above before I run them please?
EDIT:
I found this bit of PowerShell code . . .
Is this something that can be adapted, and if so, how please?
Thanks in advance.
I am trying to put together a Batch Script to run ALL of the files one after the other in SILENT mode within the Implement Folder.
I have created a Batch Script for each . . .
Code: Select all
@echo off
Set Folder=C:\Implement
For %%i In (%Folder%\*.reg) Do (regedit /s %%i)
echo.
echo REG Implementation Completed Successfully!
Pause
EXIT
Code: Select all
@echo off
Set Folder=C:\Implement
Set PowerShellExe=%windir%\System32\WindowsPowerShell\v1.0\powershell.exe
For %%i In (%Folder%\*.ps1) Do (%PowerShellExe% -NoProfile -ExecutionPolicy Bypass -Command %cd%\%%i)
echo.
echo PS Implementation Completed Successfully!
Pause
EXIT
Code: Select all
@echo off
Set Folder=C:\Implement
Set cmdExe=%windir%\System32\cmd.exe
For %%i In (%Folder%\*.bat) Do (%cmdExe% \%%i)
echo.
echo CMD Implementation Completed Successfully!
Pause
EXIT
EDIT:
I found this bit of PowerShell code . . .
Code: Select all
Get-ChildItem '.\*.reg' | ForEach{
$Result = Start-Process Reg -ArgumentList Import, $_ -Wait -PassThru
echo ( '{0} - {1}' -f $Result.ExitCode, $_.Name)
}
Thanks in advance.