Python Forum
Cant get powershell script to run with subprocess
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant get powershell script to run with subprocess
#1
hi all,

i can run up a powershell command with subprocess fine but now im trying to get subprocess working with my powershell script but its not passing the variables

heres my py script
import subprocess

un = "username"
op = "oldpassword"
cnp = "newpassword"
dom = "robo84"

subprocess.run(f'powershell.exe C:\\python\\test.ps1' , shell=True)
ps1 script
write-host $un
write-host $op 
write-host $cnp 
write-host $dom
but when i run in cmd, it runs with no errors but i get 4 blank lines

thanks,
rob
Reply


Messages In This Thread
Cant get powershell script to run with subprocess - by robertkwild - Jun-27-2024, 10:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Show powershell errors in flask-wtf web form robertkwild 14 422 Jun-30-2024, 03:15 PM
Last Post: robertkwild
  Running powershell command in flask wtf form robertkwild 10 349 Jun-27-2024, 09:49 AM
Last Post: robertkwild
  Passing web form to powershell robertkwild 1 284 Jun-14-2024, 10:16 AM
Last Post: Akshiya
  using PowerShell from Python script for mounting shares tester_V 8 858 Mar-12-2024, 06:26 PM
Last Post: tester_V
  PowerShell & Python deep_logic 2 850 Jun-06-2023, 06:34 AM
Last Post: buran
  Running script with subprocess in another directory paul18fr 1 4,567 Jan-20-2023, 02:33 PM
Last Post: paul18fr
  How to write a part of powershell command as a variable? ilknurg 2 1,242 Jul-26-2022, 11:31 AM
Last Post: ilknurg
Photo Windows 10 PowerShell doesn't work Amy 3 4,061 Apr-27-2021, 01:33 PM
Last Post: jefsummers
  how to set focus when running a script using subprocess Malt 0 3,252 Sep-26-2019, 08:07 AM
Last Post: Malt
  Using Subprocess.Popen to start another python script running in background on Window johnb546 0 13,823 Jun-01-2018, 01:57 PM
Last Post: johnb546

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020