Session 0 UI

//Session 0 UI
Session 0 UI 2015-06-19T12:42:52+00:00

The Toolkit Forums General Session 0 UI

  • Author
    Posts
  • Rudolf
    Participant
    Post count: 3
    #343 |

    We are trying to use PDT for software installation using gpo. Is there any way to inform user that sw installation is running in session 0 phase of computer boot?

    PDT detects 0 session and switch our setting ( -DeploymentType Interactive) to NoInteractive

    Thx

    Rudolf

    • This topic was modified 2 years, 4 months ago by  Rudolf.
  • Muhammad Mashwani
    Keymaster
    Post count: 118

    If you are in session 0, then it’s impossible to display something to a user. You have to use something like ServiceUI.exe to break out of session 0 and display you message to a specific user in a logged in user session.

  • Paul
    Participant
    Post count: 7

    I’ve been using the following in Microsoft’s Configuration Manager (SCCM) to allow installs when either no user is logged on or when a user is logged on (show dialogs), perhaps you can modify the batch files to run in your situation.

    I think that I’ve found a working method to allow an SCCM 2012 application to be used in both task sequences and with users.

    Create an application with two deployment types (one for x64 and one for x86). set the user experience to both to:

    Install for system; Whether or not a User is logged on.

    Create a batch file to be called for each deployment type (x64 and x86), put this command into the file:

    %SYSTEMROOT%\System32\qprocess.exe * | find /i “explorer.exe” >nul 2>&1 && (%~dp0ServiceUIx64.exe %~dp0Deploy-Application.exe Install) || (%~dp0Deploy-Application.exe Install)

    (for x86 use ServiceUIx86.exe)

    What this command does is find if the process “explorer.exe” is running and thus there is a logged on user, if so use ServiceUI.exe to launch Deploy-Application.exe to show the dialogs to the user, if no user logged on (such as in the Task Sequence) just run the Deploy-Application.exe

    You can change the Install command to Uninstall to create the Uninstall batch files

  • Alan
    Participant
    Post count: 14

    I could have sworn, I have deployed a package in the past with SCCM with PDT and Show-installation would always show the dialog even if set to “Whether or not user is logged on”.

    But I see in the logs session 0 detected, setting to non-interactive.
    Was it before 3.5.0?

    • Pelle
      Participant
      Post count: 100

      So could I. Do you have any new discoveries on this? Desperately trying to figure out a solution to keeping the same application deployment type for both OSD and machines up-and-running.

      I tried Pauls suggestion, but it doesn’t break out of session 0. I changed the command a little bit as follows:
      %SYSTEMROOT%\System32\qprocess.exe * | find /i "explorer.exe" >nul 2>&1 && (%~dp0ServiceUIx64.exe powershell.exe -file %~dp0Deploy-Application.ps1 -DeploymentType Install -DeployMode Interactive) || (%~dp0Deploy-Application.exe Install)

      Works just fine while executing it through PsExec manually on the client, but not when deploying with CM. OSD works though.

      [Edit]: It’s as if the script engine ignores the supplied switches when run from CM.
      [Initialization] :: Session 0 detected, process not running in user interactive mode; deployment mode set to [NonInteractive]. PSAppDeployToolkit 28.07.2015 15:04:54 2604 (0x0A2C)

      • This reply was modified 2 years, 2 months ago by  Pelle.
    • Pelle
      Participant
      Post count: 100

      My apologies, Paul’s suggestion did in fact work in both scenarios. I had a typo in my switches which caused the error.

      /Pelle

    • Pelle
      Participant
      Post count: 100

      Just to confuse this further. I’m having problems still. I find the following entry in the install log on some clients, when I know for a fact it is not true:
      [Initialization] :: Successfully loaded COM Object [Microsoft.SMS.TSEnvironment]. Therefore, script is currently running from a SCCM Task Sequence.
      … which leads me to think that I might have clients out there which have failed during OSD and haven’t completed a proper cleanup, which would explain the inconsistent behavior on my clients.

      So, I’m sure Paul’s suggestion does work, but at least in my case I would’ve liked another way of detecting if TS is running or not. Would be interested to hear if anyone else stumbled upon this issue.

  • Jamie
    Participant
    Post count: 1

    Glad Im not the only one

    At the moment I have to create 2 applications, one for users, the other for TS. I had previously added 2 deployment types to the app, one which fires if a user is logged on, the other if a user isn’t. Its odd you cant add the deployment type for no logged on users to the TS, since this is the same environment, technically, as a TS.

    Ive tried running the batch file, but as Pelle decribes, it seems to think its running in session 0, since it doesn’t prompt the user to close apps, give them a countdown etc.

    This is pretty much torpedoing using psappdeploy for us, which is a real shame.

  • Dean
    Participant
    Post count: 1

    I use two deployment types, one whether or not user is logged on with a requirement that the CcmExec Provisioningmode key is true (this is set for OSD). This deployment type is priority 1.

    The second deployment type is the usual PADT deployment with SCCM.

  • Ryan
    Participant
    Post count: 1

    I can not get this to work. I have one application in SCCM with one deployment type. The deployment type is set to install for system, whether or not the user is logged in. We want to be able to show a progress bar for installation to the user if they are logged in. Looking at the PS app tool kit, they say I say just call the function Execute-ProcessAsUser. I have simplified it by just trying to call Execute-ProcessAsUser -Path “C:\Windows\System32\calc.exe” as a test. If I test it manually on my box through a cmd prompt running as system 0 it launches. But when I deploy it through SCCM as a deployment, it doesn’t launch calc.exe for the user. I am running out of ideas, so any help would be great!

  • Tim
    Participant
    Post count: 4

    Has anyone had any other success with this? We still get our installs installing as non-interactive via SCCM when the deadline is reached since the system not the user initiates the install.

    We need to keep the interaction to whether or not and install as system for imaging purposes.

  • Glenn
    Participant
    Post count: 2

    This is working really well when we run Deploy-Application.exe Install as a user-initiated install either from a PowerShell prompt, or via them clicking a Required deployment that has not yet met the deadline from Software Center. The moment that the Required deployment deadline has passed, the install starts in non-interactive mode and they don’t see any prompts. This is precisely the scenario that I need to show defer or close apps prompts, otherwise I’m not getting the main benefit of using PSADT.

    I saw this: http://psappdeploytoolkit.codeplex.com/workitem/98

    It’s from a couple of years ago and talks about v4. I’m guessing that’s still a while off. How are other people handling this now? Is ServiceUI the only option still, and has anyone got this working?

    I have made sure that the Logon requirement is set to Whether or not a user is logged on, and Allow users to view and interact with the program installation. This bit is definitely working, as it’s working when run as either an Available installation or via clicking the install from ConfigMgr prior to the deadline.

  • Dan
    Participant
    Post count: 1

    I ran into this as well when pushing mandatory application deployments. For some reason the “Whether or not a user is logged in” causes the serviceUI.exe process to fail with the oh so helpful “-1” error code. Since that tool does not provide any usable output/logging, I had to do the following:
    Create a Global Condition (Named “User Session” )to detect user session. I used a vbscript calling “query user” and parsing the details, returning integer values. 0 if no user is logged in and the first session number found in the event a user is logged in. This would provide visibility into RDP users (session 2+) as well as console (session 1).


    Set objShell = WScript.CreateObject("WScript.Shell")
    Set objExecObject = objShell.Exec("cmd /c query user")
    Do While Not objExecObject.StdOut.AtEndOfStream
    strText = objExecObject.StdOut.ReadLine()
    If Instr(lcase(strText), "no user exists") > 0 Then
    wscript.echo 0
    Exit Do
    elseif instr(lcase(strtext), "sessionname") > 0 then ' it found a session, let's find the first one and return the session ID
    bUser=True
    elseif bUser=True then
    strText=replace(trim(strtext)," "," ") : strText=replace(strtext," "," ") : strText=replace(strtext," "," ") :strText=replace(strtext," "," ") : strText=replace(strtext," ",";")
    arrText = split(strText,";")
    wscript.echo arrtext(2)
    exit do
    End If

    Loop

    I then used two deployment types, the first one set to Only when a user is logged in with “Allow users to interact with this program” checked. It had a requirement of User Session > 0. A script called the appropriate bit-level serviceui.exe
    The second deployment type was set to when no one is logged in which calls “deploy-Application.exe”.

    This combination is the only way I reliably got the UI to present itself, unfortunately, when using applications with mandatory deployments.

    • This reply was modified 9 months ago by  Dan.
  • Francois
    Participant
    Post count: 100

    Hi,

    We had similar problem and found a workaround.
    1. From your script test if someone is log on.
    2. If log on then run executeas process user function. Use this function to run a script displaying your message. What this function is doing is creating a Schedule task and running this task Under the user name. So instead making your script running this in session 0, Windows will run it Under the user session.

    Thanks,

  • Tim
    Participant
    Post count: 4

    Can you expand on this? Are you putting it in the PSADT script itself? Not in SCCM detection script.

    Would you mind sharing the code and function you are using?

  • Francois
    Participant
    Post count: 100

    Basically, what you have to do is

    1. using the $currentconsoleusersession to determine if someone is logged on.

    <code> If ($CurrentConsoleUserSession -eq $null) {
                    Write-log &quot;Aucun utiisateur de connecté&quot;
                    set-variable -name B_UtilisateurConnecte -visibility public -Scope Script -value $false
                }
                If ($CurrentConsoleUserSession -ne $null) {
                    Write-log &quot;Un utilisateur est connecté&quot;
                    set-variable -name B_UtilisateurConnecte -visibility public -Scope Script -value $true
                    Write-Log &quot;L&#039;utilisateur suivant est connecté à la console [$($CurrentConsoleUserSession.NTAccount)] (utilisateur avec le contrôle physique du moniteur, clavier et souris).&quot; -Source $appDeployToolkitName
                }</code>

    2. If somoneone is loggedon then run the function execute-processasuser with a script of a winbatch code. We created a box with winbatch but running a script would be ok too

    Execute-ProcessAsUser -Path "$var_UninstallFolder\$Str_UIFichierActionfinal" -Parameters "“$var_UninstallFolder\$Str_UINomFichMsg"" -wait

    What that function is doing is creating a Schedule job and running it Under the user session. If you get a look to the set-activesetup function, it is using Execute-processasuser. to run the active setup Under the current user session so you don’t have to logout/login to run the active setup.

  • Joshua
    Participant
    Post count: 5

    I remember coming across this issue before, here’s my old post from the old codeplex forums
    https://psappdeploytoolkit.codeplex.com/discussions/465270

    After further testing with v3.6.0, I think I’ve got everything working to properly display UI to the current logged on user of a machine.

    In SCCM, I have the following set:

    Install: Install.bat

    Uninstall: Uninstall.bat

    Install for System
    Whether or not a user is logged on
    Normal

    Here are the command lines for each bat file:
    Install: PSExec.exe -si -accepteula %~dp0ServiceUI.exe %~dp0Deploy-Application.exe
    Uninstall: PSExec.exe -si -accepteula %~dp0ServiceUI.exe %~dp0Deploy-Application.exe Uninstall

    I also have copies of both PSExec.exe and ServiceUI.exe (x86 version) at the root of the toolkit.

    So far I’ve had success on both 64-bit and 32-bit machines. For some reason, running PSExec as SYSTEM, then running ServiceUI after, avoids the usual “Error Code 5” on 32-bit machines. The implementation may be a bit cumbersome, but it DOES WORK. If anyone else is interested, feel free to do the same.

You must be logged in to reply to this topic.