Installing Python with Powershell and "System" Account

JAMES, Clinton 0 Reputation points
2023-04-03T05:50:33.3+00:00

Hi,

I am doing my head in here. I have an installation script that works perfectly for everything through Windows Task Scheduler except Python. It uses the system account on the server to run this task.

It doesn't error when installing Python, but what happens is "Python Installer" is installed but the actual python application is still missing.

If i run the same installer script remotely with my own credentials rather than using the system account, then python fully installs. I don't know why Windows seems to not want to cooperate with the installing when it should actually work.

Is anybody able to guide me on an install method I can employ to get around this as the process needs to use task Scheduler this way.

Thank you

Windows for business Windows Server User experience PowerShell
{count} votes

2 answers

Sort by: Most helpful
  1. John Smith 0 Reputation points
    2023-04-03T12:28:47.19+00:00
    Hello there,
    
    This might be due to account privileges to your account instead of system account.
    
    You can also try package installers like a Chocolatey and see if that helps.
    
    You can not install it without administrator privileges. It would be lack of security. What you can use in pipelines for instance is:
    
    $url = "https://www.python.org/ftp/python/3.7.6/python-3.7.6-amd64.exe"
    $output = "C:/tmp/python-3.7.6-amd64.exe"
    
    if (Test-Path $output) {
        Write-Host "Script exists - skipping installation"
        return;
    }
    
    New-Item -ItemType Directory -Force -Path C:/tmp
    
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    Invoke-WebRequest -Uri $url -OutFile $output
    
    & $output /passive InstallAllUsers=1 PrependPath=1 Include_test=0 
    
    But still, Admin rights are required
    
    Hope this resolves your Query !!
    
    --If the reply is helpful, please Upvote and Accept it as an answer--
    

  2. MotoX80 36,291 Reputation points
    2023-04-03T12:52:02.3933333+00:00

    Sounds like a problem with the Python installer. Does it have a command line switch to enable verbose logging? Enable that and then check the log to see what the installer did. If you find an error, you will likely need to ask for help in a Python support forum.

    There's this. https://bugs.python.org/issue41800


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.