[Python] PsExec works from PowerShell but not by Python

Discussão em 'Python' iniciado por Stack, Junho 16, 2025.

  1. Stack

    Stack Membro Participativo

    I know there is a package PyPsExec but I'm asking why this happens and how to solve it. The command psexec -s -i -d \\<PC-NAME> -u <UserName> -p <Password> <Command> works when typed manually at PowerShell, however with Python as:

    from subprocess import Popen,PIPE
    p = Popen("""psexec -s -i -d \\<PC-NAME> -u <UserName> -p <Password>
    <Command>""", stdin=PIPE, stdout=PIPE, shell= True )
    stdout, stderr = p.communicate()
    print(stdout, stderr)


    I get:

    'psexec' is not recognized as an internal or external command,
    operable program or batch file.
    b'' None


    Any idea why? PsExec is configured at variable path. I get the same error for PsKill.

    Continue reading...

Compartilhe esta Página