Using Powershell in C code

Is there a way to run powershell commands through C code? For example, Im trying to download image from url, but without success. Word of advice?

Attached: Warrior of Boar.png (1920x1080, 1.16M)

Other urls found in this thread:

stackoverflow.com/questions/22077802/simple-c-example-of-doing-an-http-post-and-consuming-the-response
is2.Jow
curl.haxx.se/download.html
twitter.com/SFWRedditVideos

Why not use a C http library

install gentoo and use curl

would you be so kind and provide some links with more info? I spent last two days browsing stack overflow to find optimal way to download data from url but most of that sh*t is solved in object-oriented languages

Just use wget, wintoddler.

Just use system("powershell 'download...' ")

also most people closed topics with wget and curl but Im looking for way, that works on Windows

Are you slow?
stackoverflow.com/questions/22077802/simple-c-example-of-doing-an-http-post-and-consuming-the-response

Install a real OS. Windows is for retards.

You can use system("powershell -Command 'Invoke-WebRequest ...'"), I guess.
Or start up PowerShell with CreateProcess() and figure out how to give it commands via stdin.

Windows 10 includes curl, now that you mention it, so you can just do system("curl.exe ...").

>Im looking for way, that works on Windows
install wget or curl on windows?

Attached: 1537792300195.png (969x702, 910K)

system("powershell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12");
system("powershell Invoke-Webrequest -Uri "is2.Jow Forums.org/g/1562086287919.png" -Outfile d:/hobo/pic.jpg");

I was trying something like this but second command has wrong syntax and first command just loops terminal.

Why not just write a powershell script if you’re gonna use powershell? If you want to use C just use libcurl, it’s available for windows, but I can’t imagine what you could be doing that requires both C and “downloading image from url” at your obviously low skill level (no offense)

Also, sorry if this looks trivial to you guys, but I´m unexperienced, wouldn´t even consider myself junior programmer

Install Linux and use Perl.

Jesus dude you can’t have quotes inside of quotes, escape them

thanks

curl.haxx.se/download.html
If you must use powershell, just install curl binary, but I would download libcurl for windows and use that if you’re trying to learn C

One thing that you are going to realize is incredibly important is that the compiler has pretty concise error messages. It’s not just a “syntax error,” it will tell you exactly where and give you a pretty good clue as to what you did wrong

See

yeah, I would rather not trigger you guys any further with questions basic for you

It's not about having basic questions it's about asking questions that would have been answered were you to google it for 5 seconds.

How do you expect PowerShell to remember your setting - which is pointless, by the way, at least on my Windows 10 machine - across invocations?

yes, I did not realise that. I was pretty tired atm

Alright, thanks for answers I think I have enough to figure it out now