From the course: Learning Assembly Language

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Executing system commands

Executing system commands - Python Tutorial

From the course: Learning Assembly Language

Start my 1-month free trial

Executing system commands

- [Narrator] We can execute a Windows command from our assembly code by using either the legacy WinExec function or using the create process function. Let's take a look at WinExec. I'll define a constant called SW_SHOW and set it to five to define the way we want the window to show when we execute. In the data area, I'll set up the command string to execute C:windows, system 32, notepad.exe, and in the code section we invoke WinExec with the address of command and SW_SHOW. So let's build this and run it and hey, presto, we get Notepad popping up. We might want to just pop up a command window. We can do that as well by executing cmd.exe, build, run, and we get our command window. If we want to run a more powerful shell, we can, of course, run PowerShell or PowerShell_ise. Let's do that. Build, build starter, build, run, and we get the annotated PowerShell.

Contents