(Aug-31-2018, 04:47 PM)Larz60+ Wrote: Please post code in code tags, not images see BBCODE
Also when posting errors, use error tags (also in above link), and make sure you post the errors verbatim.
I don't use power shell, so can't run code. command is approximate, and I would never do what you are trying to do in the first place.
Why torture yourself, it can all be done so easily using pure python code.
Suggest you post on https://social.technet.microsoft.com/For...powershell
ok this is the code :
import subprocess
def downloadfile():
mycommand = "powershell -command "$cli = New-Object System.Net.WebClient;$cli.Headers['User-Agent'] = {};$cli.DownloadFile('https://drive.google.com/uc?export=download&id=19LJ6Otr9p_stY5MLeEfRnA-jD8xXvK3m', '%appdata%\putty.exe')".format(myUserAgentString)
down = subprocess.call(mycommand)
downloadfile()
and this is the error :
Error:
File "searchmailfolder.py", line 4
mycommand = "powershell -command "$cli = New-Object System.Net.WebClient;$cli.Headers['User-Agent'] = {};$cli.DownloadFile('https://drive.google.com/uc?export=download&id=19LJ6Otr9p_stY5MLeEfRnA-jD8xXvK3m', '%appdata%\putty.exe')".format(myUserAgentString)
^
SyntaxError: invalid syntax
my code is working outside python ... the problem with python because the command line have multi " and multi $ ...