1. #21
    So I used a bit of avimanyu786's script and wrote one that works pretty well using Powershell.
    Some caveats:
    * Only tested on Windows 10
    * You need to have RemoteSigned scripts allowed to run

    The whole script is below:

    Code:
    # make sure SWF is ready to go
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    
    # add a C# class to access the WIN32 API SetForegroundWindow
    Add-Type @"
        using System;
        using System.Runtime.InteropServices;
        public class StartActivateProgramClass {
            [DllImport("user32.dll")]
            [return: MarshalAs(UnmanagedType.Bool)]
            public static extern bool SetForegroundWindow(IntPtr hWnd);
        }
    "@
    
    # wait for Uplay launcher to start running by looking for it's PID
    $uplayRunning = Get-Process upc -ErrorAction SilentlyContinue
    $mwhLimit = 1 # if Uplay is already running set the window limit to 1
    If ( $uplayRunning -eq $null ) {
        Do {
            Sleep 1
            $uplayRunning = Get-Process upc -ErrorAction SilentlyContinue
            Start-Process "C:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\Uplay.exe"
        } While ( $uplayRunning -eq $null )
        $mwhLimit = 2 # if it ws not running it sets the window limit to 2
    }
    # if it is NOT running launch it
    
    # OK time to start counting windows - when Uplay launches clean it has 2 windows "Loading' and the actual Uplay client
    $uplayMWH = @()
    Do {
        Sleep 1
        $mwh = (Get-Process upc -ErrorAction SilentlyContinue).MainWindowHandle
        If ( $mwh -ne 0 ) {
            If ( $mwh -ne $uplayMWH[-1] ) {
                $uplayMWH += (Get-Process upc -ErrorAction SilentlyContinue).MainWindowHandle
            }
        }
    } While ( $uplayMWH.Count -lt $mwhLimit )
    # counts the number of unqiue windows Uplay loads - again this should be 2, the last of which is the client itself
    [StartActivateProgramClass]::SetForegroundWindow($uplayMWH[-1]) # make the client the foreground (active) window
    sleep 1 
    [System.Windows.Forms.SendKeys]::SendWait("%{F4}") # now close it
    Save this as LaunchUplay.PS1 file to your C: someplace - I like c:\ps-scripts

    Set up a new Task in Task Scheduler.
    Control Panel -> Administrative Tools -> Task Scheduler
    Action -> Create Task
    General Tab: Name it something useful like "Uplay Launcher"
    Triggers Tab: New...
    Begin the task: At Startup
    Delay the task for: 30 seconds
    Actions Tab: New...
    Program Script: powershell.exe
    Add arguments: -windowstyle hidden "c:\ps-scripts\LaunchUplay.ps1"
    Click 'OK'

    That's it, you're done.
     1 people found this helpful
    Share this post

  2. #22
    Follow-up : If you are impatient and start doing things the moment Windows starts, be aware that the script isn't THAT picky. If you see Uplay launching and start working on thigs, and don't give it that 1 second it needs to set it to Foreground and ALT+F4 it, it'll clsoe whatever window you are currently in.

    I safely set that last Sleep 1 statement to Sleep -m 500 (hald a second) to help with that, but since I cannot edit my post, I have to put it here.
     1 people found this helpful
    Share this post

  3. #23
    Thanks EvilTwinTepe that works great, I appreciate you taking the time to share this and explain how to set it up.

    Now if only I could get it to minimize Discord, unfortunately I could only get it to run Discord, powershell had a scrolling list of errors.
    Share this post

  4. #24
    Is there no way to stop the script window from displaying?
    Share this post

  5. #25
    Any news on this topic?
    I'm really not willing to run some scripts to get this done.

    Oh and while you're at it... please stop the client to pop-up everytime i quit a game.
    Thank you.
    Share this post

  6. #26
    Originally Posted by EvilTwinTepe Go to original post
    So I used a bit of avimanyu786's script and wrote one that works pretty well using Powershell.
    Some caveats:
    * Only tested on Windows 10
    * You need to have RemoteSigned scripts allowed to run

    The whole script is below:

    Code:
    # make sure SWF is ready to go
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    
    # add a C# class to access the WIN32 API SetForegroundWindow
    Add-Type @"
        using System;
        using System.Runtime.InteropServices;
        public class StartActivateProgramClass {
            [DllImport("user32.dll")]
            [return: MarshalAs(UnmanagedType.Bool)]
            public static extern bool SetForegroundWindow(IntPtr hWnd);
        }
    "@
    
    # wait for Uplay launcher to start running by looking for it's PID
    $uplayRunning = Get-Process upc -ErrorAction SilentlyContinue
    $mwhLimit = 1 # if Uplay is already running set the window limit to 1
    If ( $uplayRunning -eq $null ) {
        Do {
            Sleep 1
            $uplayRunning = Get-Process upc -ErrorAction SilentlyContinue
            Start-Process "C:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\Uplay.exe"
        } While ( $uplayRunning -eq $null )
        $mwhLimit = 2 # if it ws not running it sets the window limit to 2
    }
    # if it is NOT running launch it
    
    # OK time to start counting windows - when Uplay launches clean it has 2 windows "Loading' and the actual Uplay client
    $uplayMWH = @()
    Do {
        Sleep 1
        $mwh = (Get-Process upc -ErrorAction SilentlyContinue).MainWindowHandle
        If ( $mwh -ne 0 ) {
            If ( $mwh -ne $uplayMWH[-1] ) {
                $uplayMWH += (Get-Process upc -ErrorAction SilentlyContinue).MainWindowHandle
            }
        }
    } While ( $uplayMWH.Count -lt $mwhLimit )
    # counts the number of unqiue windows Uplay loads - again this should be 2, the last of which is the client itself
    [StartActivateProgramClass]::SetForegroundWindow($uplayMWH[-1]) # make the client the foreground (active) window
    sleep 1 
    [System.Windows.Forms.SendKeys]::SendWait("%{F4}") # now close it
    Save this as LaunchUplay.PS1 file to your C: someplace - I like c:\ps-scripts

    Set up a new Task in Task Scheduler.
    Control Panel -> Administrative Tools -> Task Scheduler
    Action -> Create Task
    General Tab: Name it something useful like "Uplay Launcher"
    Triggers Tab: New...
    Begin the task: At Startup
    Delay the task for: 30 seconds
    Actions Tab: New...
    Program Script: powershell.exe
    Add arguments: -windowstyle hidden "c:\ps-scripts\LaunchUplay.ps1"
    Click 'OK'

    That's it, you're done.
    Thanks for taking the time to improve it ...
     1 people found this helpful
    Share this post

  7. #27

    You're a star!

    Originally Posted by EvilTwinTepe Go to original post
    Follow-up : If you are impatient and start doing things the moment Windows starts, be aware that the script isn't THAT picky. If you see Uplay launching and start working on thigs, and don't give it that 1 second it needs to set it to Foreground and ALT+F4 it, it'll clsoe whatever window you are currently in.

    I safely set that last Sleep 1 statement to Sleep -m 500 (hald a second) to help with that, but since I cannot edit my post, I have to put it here.
    The last one only? Thanks man! works great like this, you're a star!
    Originally Posted by EvilTwinTepe Go to original post
    # make sure SWF is ready to go
    [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

    # add a C# class to access the WIN32 API SetForegroundWindow
    Add-Type @"
    using System;
    using System.Runtime.InteropServices;
    public class StartActivateProgramClass {
    [DllImport("user32.dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool SetForegroundWindow(IntPtr hWnd);
    }
    "@

    # wait for Uplay launcher to start running by looking for it's PID
    $uplayRunning = Get-Process upc -ErrorAction SilentlyContinue
    $mwhLimit = 1 # if Uplay is already running set the window limit to 1
    If ( $uplayRunning -eq $null ) {
    Do {
    Sleep 1
    $uplayRunning = Get-Process upc -ErrorAction SilentlyContinue
    Start-Process "C:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\Uplay.exe"
    } While ( $uplayRunning -eq $null )
    $mwhLimit = 2 # if it ws not running it sets the window limit to 2
    }
    # if it is NOT running launch it

    # OK time to start counting windows - when Uplay launches clean it has 2 windows "Loading' and the actual Uplay client
    $uplayMWH = @()
    Do {
    Sleep 1
    $mwh = (Get-Process upc -ErrorAction SilentlyContinue).MainWindowHandle
    If ( $mwh -ne 0 ) {
    If ( $mwh -ne $uplayMWH[-1] ) {
    $uplayMWH += (Get-Process upc -ErrorAction SilentlyContinue).MainWindowHandle
    }
    }
    } While ( $uplayMWH.Count -lt $mwhLimit )
    # counts the number of unqiue windows Uplay loads - again this should be 2, the last of which is the client itself
    [StartActivateProgramClass]::SetForegroundWindow($uplayMWH[-1]) # make the client the foreground (active) window
    sleep -m 500
    [System.Windows.Forms.SendKeys]::SendWait("%{F4}") # now close it
    Oh and I found this:
    mshta vbscript:Execute("CreateObject(""Wscript.Shell""). Run ""powershell -NoLogo -Command """"& 'C:\ps-scripts\LaunchUplay.ps1'"""""", 0 : window.close")
    here:
    https://stackoverflow.com/questions/...aying-a-window

    So a Task scheduled of mshta would have the arguments vbscript:Execute("CreateObject(""Wscript.Shell""). Run ""powershell -NoLogo -Command """"& 'C:\ps-scripts\LaunchUplay.ps1'"""""", 0 : window.close") and would run hidden
     1 people found this helpful
    Share this post