Automating IE whith powershell - Running Schedule Task (Run whether user is logged on or not) RRS feed

  • Question

  • Well like the title say i made a little powershell task that i need to run even i stay logged or not. need run this on windows server 2008 r2 and i have admin user

    here's the script:

    $ie = new-object -ComObject "InternetExplorer.Application"

    $requestUri = "https://any_web"

    $ie.visible = $true
    $ie.silent = $true

    while($ie.Busy) { Start-Sleep -Milliseconds 100 }

    $doc = $ie.Document

    $user = $doc.getElementsByTagName("input") | ? { $ -eq "username" }
    $pwd = $doc.getElementsByTagName("input") | ? { $ -eq "password" }
    $btn = $doc.getElementsByTagName("button") | ? { $ -eq "user_submitted_login_form" }

    $user.value = "user"
    $pwd.value = "password"

    while($ie.Busy) { Start-Sleep -Milliseconds 100 }

    $ie.Document.body.getAttributeNode("onload") | Out-File -FilePath C:\Users\folder\weblogin.txt

    If i run this from:

    powershell works fine and weblogin.txt have data

    ssis package work fine and weblogin.txt have data, but if i create a job and schedule it, like it works fine but weblogin.txt have not data

    windows task schedule works fine if i setup "Run only when user is logged on" and weblogin.txt have data

    if i try yo create a job and schedule in server or if i try to  schedule like windows task to "Run whether user is logged on or not" apparently work fine but weblogin.txt have not data

    i have not idea what can i do...  i read in an article somtehing like this

    You need to create a Desktop folder in

    C:\Windows\System32\config\ systemprofile\

    but nothing change...

    I hope some1 of you can help!


    if you know about a different but functional way to do this... i'm all ears-
    Tuesday, October 15, 2019 11:39 PM


  • You cannot run IE in a scheduled task when you are not logged in. It is strictly forbidden.


    • Marked as answer by Lufoque Wednesday, October 16, 2019 12:23 AM
    Tuesday, October 15, 2019 11:50 PM

All replies