Launch PowerShell from a .bat file
Solved
Shadow81
-
brucine Posted messages 24389 Registration date Status Membre Last intervention -
brucine Posted messages 24389 Registration date Status Membre Last intervention -
Hello everyone!
I'm trying to run this .Bat code in PowerShell:
So I created this code to run it with PowerShell:
However, I get this:
And when I launch my .Bat from PowerShell, it opens CMD, while I want it to be launched in PowerShell.
I'm sending you the .bat script hoping I am clear enough in my statements. If not, I apologize ^^' I often have trouble making myself understood.
Thank you in advance for the help you'll provide me ^^
I'm trying to run this .Bat code in PowerShell:
@echo off
cls
set /p IP="Enter an IP="
set /p Incrementation="Enter a Date (YY-MM-DD)="
./mtcli_memo.exe %IP% %Incrementation% >my_file.csv
echo.
So I created this code to run it with PowerShell:
@echo off
Powershell.exe -executionpolicy remotesigned -File C:\Users\Shadow81\Desktop\Code.ps1
pause
However, I get this:
The argument « C:\Users\Shadow81\Desktop\Code.ps1 » for parameter -File does not exist. Specify the path to an existing « .ps1 » file for the argument of the -File parameter.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Press any key to continue...
And when I launch my .Bat from PowerShell, it opens CMD, while I want it to be launched in PowerShell.
I'm sending you the .bat script hoping I am clear enough in my statements. If not, I apologize ^^' I often have trouble making myself understood.
Thank you in advance for the help you'll provide me ^^
2 réponses
Hello,
Why run it in batch rather than directly in Powershell?
Syntax here: https://stackoverflow.com/questions/19335004/how-to-run-a-powershell-script-from-a-batch-file
Why run it in batch rather than directly in Powershell?
Syntax here: https://stackoverflow.com/questions/19335004/how-to-run-a-powershell-script-from-a-batch-file
brucine
Posted messages
24389
Registration date
Status
Membre
Last intervention
4 098
Moreover, the first code is a .bat file, not a .ps1 file....