batch-file-es Windows
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Capítulo 5: Archivos por lotes e híbridos
Powershell
Examples
Ejecutar Powershell con archivos temporales
Esto ha sido mencionado en otros temas híbridos una y otra vez. El método de la vieja escuela,
pero fácil de ejecutar Powershell es por:
• echo del script Powershell en un script temporal
• Ejecutar el script temporal
• Opcionalmente eliminar el script temporal.
Este es un script de ejemplo.
@echo off
echo powershell-command>Temp.ps1
echo another line>>Temp.ps1
rem echo the script into a temporary file
powershell -File Temp.ps1
rem execute the temporary script
del Temp.ps1
rem Optionally remove the temporary script
El método anterior requiere toneladas de declaraciones de echo si se requiere un script largo, aquí
hay un mejor método sugerido por @Aacini
@echo off
setlocal
rem Get the number of the "<resource>" line
for /F "delims=:" %%a in ('findstr /N "<resource>" "%~F0"') do set "start=%%a"
rem Skip such number of lines and show the rest of this file
(for /F "usebackq skip=%start% delims=" %%a in ("%~F0") do echo %%a) > Temp.ps1
powershell -File Temp.ps1
del /f /s /q Temp.ps1
goto :EOF
<resource>
PS
Powershell script
Use el comando POWERSHELL para ejecutar el comando Powershell de 1
https://riptutorial.com/es/home 14