Python Forum
using PowerShell from Python script for mounting shares
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using PowerShell from Python script for mounting shares
#3
I thought when I open the file with "with open..." it closes automatically...
Should I use instead of it :
    #with open('C:/Scripts/somescript/Connect-0.ps1','w') as ps :
    ps = open('C:/Scripts/somescript/Connect-0.ps1','w')
        ps.write(f"{ln1}\n")
        ps.write(f"{ln2}\n")
        ps.close()
        subprocess.call("C:/Scripts/somescript/Connect-0.ps1")
Thank you for working on weekends! Wink
Reply


Messages In This Thread
RE: using PowerShell from Python script for mounting shares - by tester_V - Mar-10-2024, 04:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Passing web form to powershell robertkwild 0 128 May-28-2024, 02:18 PM
Last Post: robertkwild
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,655 Jun-29-2023, 11:57 AM
Last Post: gologica
  PowerShell & Python deep_logic 2 804 Jun-06-2023, 06:34 AM
Last Post: buran
  How to write a part of powershell command as a variable? ilknurg 2 1,201 Jul-26-2022, 11:31 AM
Last Post: ilknurg
Photo Windows 10 PowerShell doesn't work Amy 3 4,009 Apr-27-2021, 01:33 PM
Last Post: jefsummers
  How to kill a bash script running as root from a python script? jc_lafleur 4 6,131 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,405 May-28-2020, 05:27 PM
Last Post: micseydel
  Package python script which has different libraries as a single executable or script tej7gandhi 1 2,707 May-11-2019, 08:12 PM
Last Post: keames
  Powershell Session translation to Python; Session code seems to not work Maverick494 1 3,692 Jun-26-2018, 05:16 PM
Last Post: Maverick494
  Check Python version from inside script? Run Pythons script in v2 compatibility mode? pstein 2 9,934 Jul-07-2017, 08:59 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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