Red Slash
Red Slash

Reputation: 11

How to use Windows cmd to download an executable file and run the downloaded executable?

Currently the command below executed from within PowerShell works.

cmd /c bitsadmin /transfer 8 https://www.example.com/hello.exe %temp%\St.exe

I need to start St.exe in the same command line.

Can you please help me out?

The error message in PowerShell:

The token '&&' is not a valid statement separator in this version. At line:1 char:88 + cmd /c bitsadmin /transfer 8 example.com/hello.exe %temp%\St.exe && <<<< start St.exe + CategoryInfo : ParserError: (&&:String) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine

Upvotes: 1

Views: 5418

Answers (2)

lit
lit

Reputation: 16236

Multiple commands can be placed on the same line by using a SEMICOLON ';' to separate them.

cmd /c bitsadmin /transfer 8 https://www.example.com/hello.exe; %TEMP%\St.exe

In recent versions of Windows, there may be an alternate stream in the file which can be used to identify that the file came from the outside world and be prevented from running. I thought you wanted to download hello.exe, then run St.exe.

Upvotes: 0

Patrick Cuff
Patrick Cuff

Reputation: 29786

If you're using Powsershell 3.0 or better, you can try using the Stop-Parsing symbol:

& cmd --% /c bitsadmin /transfer 8 https://www.example.com/hello.exe %temp%\St.exe

Upvotes: 0

Related Questions