Forum > Windows
run command Powershell
Ecsa:
Hello everyone, I'm trying to execute the entire command line that you will see below via powershell.
--- Quote ---Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
--- End quote ---
Using this code but I don't have any favorable results.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ChocoPS:= TProcess.Create(Form2);ChocoPS.Options:=[poUsePipes,poWaitOnExit,poNoConsole,poStderrToOutPut];ChocoPS.Executable:='PowerShell.exe';ChocoPS.Parameters.Add('Set-ExecutionPolicy Bypass -Scope Process -Force;');ChocoPS.Parameters.Add('[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;');ChocoPS.Parameters.Add('iex ((New-Object System.Net.WebClient).DownloadString("https://community.chocolatey.org/install.ps1"))');ChocoPS.Active:=True;Memo1.Lines.LoadFromStream(ChocoPS.Output);ChocoPS.Free;
Is there a way to execute the commands in question?
marcov:
Find the syntax how this would execute on the commandline with explicite a powershell invocation.
Then convert that to tprocess code with a parameters.add for each word (space separated), except for quoted parts, pass them as a single parameters.add without quotes.
BobDog:
Does this work?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- function system(s:pchar):integer ; cdecl external 'msvcrt.dll' name 'system'; var s:ansistring='PowerShell.exe'+#13#10+'Set-ExecutionPolicy Bypass -Scope Process -Force;'+#13#10+'[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;'+#13#10+'iex ((New-Object System.Net.WebClient).DownloadString("https://community.chocolatey.org/install.ps1"))'; begin writeln(s); writeln; system(pchar(s));writeln('Done'); readln; end.
Jurassic Pork:
Hello,
--- Quote from: Ecsa on February 10, 2022, 06:07:31 pm ---Hello everyone, I'm trying to execute the entire command line that you will see below via powershell.
--- Quote ---Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
--- End quote ---
Using this code but I don't have any favorable results.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ChocoPS:= TProcess.Create(Form2);ChocoPS.Options:=[poUsePipes,poWaitOnExit,poNoConsole,poStderrToOutPut];ChocoPS.Executable:='PowerShell.exe';ChocoPS.Parameters.Add('Set-ExecutionPolicy Bypass -Scope Process -Force;');ChocoPS.Parameters.Add('[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;');ChocoPS.Parameters.Add('iex ((New-Object System.Net.WebClient).DownloadString("https://community.chocolatey.org/install.ps1"))');ChocoPS.Active:=True;Memo1.Lines.LoadFromStream(ChocoPS.Output);ChocoPS.Free;
Is there a way to execute the commands in question?
--- End quote ---
in the DownloadString Method replace double quote with single quote like this :
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ChocoPS.Parameters.Add('iex ((New-Object System.Net.WebClient).DownloadString(''https://community.chocolatey.org/install.ps1''))');
Friendly, J.P
badmintonfan:
I tested it within windows 10 and powershell 5.1,and found only few cmdlet can run,I have tested get-process also,but thers is no result
procedure TForm1.Button1Click(Sender: TObject);
var ChocoPS : TProcess;
oput: ansistring;
begin
ChocoPS:= TProcess.Create(Form1);
ChocoPS.Options:=[poUsePipes,poWaitOnExit,poNoConsole,poStderrToOutPut];
ChocoPS.Executable:='PowerShell.exe';
//ChocoPS.Parameters.Add('Get-WmiObject -Class Win32_BIOS -ComputerName .');
//ChocoPS.Parameters.Add('whoami /upn');
ChocoPS.Parameters.Add('Get-NetAdapter');
ChocoPS.Active:=True;
//oput:=ChocoPS.Output;
Memo1.Lines.LoadFromStream(ChocoPS.Output,Tencoding.ANSI);
//memo1.Append(oput);
ChocoPS.Free;
Navigation
[0] Message Index
[#] Next page