Box to ask a customer to close his session

//Box to ask a customer to close his session
Box to ask a customer to close his session 2016-11-19T19:59:36+00:00

The Toolkit Forums General Box to ask a customer to close his session

  • Author
    Posts
  • François
    Participant
    Post count: 1

    Hi,

    I posted 2 times before last friday but none of the post are showing. So I will try again. With SCCM, I am deploying an application using the SCCM 2012 R2 model. The application is set to run whatever the session is logon or logoff and running hidden.

    During the deployment the user is logged on.

    I would like to show a wndows to ask the user to close his session with a ok button. So I tried a Show-dialogbox but in the logs I am seeing a session 0 is active and then the Window is not showing.

    What should I use?
    I was believing a session 0 would be if noone would be logged on. We are using the latest PSADTK 3.6.8.

    Thanks

    François

  • Francois
    Participant
    Post count: 105

    Hi,

    Not very much peoples on this forum. PSADTK is a very wonderful tool.

    OK, I will write what may be a start for an answer.
    So If I understand correctly, as soon as an application is send with SCCM (even if someone is already connect to the console), the script will turn as non interactive.

    This is wonderfull but it has some downside.
    1. How showing to the customers, the computer would need to reboot or the customers has to close his session.
    2. How asking a Customer he need shutting down IE before the installation?

    As I don’t have SCCM at home, I tried the following.
    1. Create a script to create another script at the computer root. The first script is like my applications. If I need asking a Customer to close his session, then the second one will be the one with the window.

    So the first script will look like that:

    <code>[string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent 
    [string]$moduleAppDeployToolkitMain = &amp;quot;$scriptDirectory\_Include\AppDeployToolkit\AppDeployToolkitMain.ps1&amp;quot;
    . $moduleAppDeployToolkitMain
    
    if ($CurrentConsoleUserSession) {
    
        Write-log &amp;quot;Détection de la présence d&#039;un utilisateur connecté au poste&amp;quot;
        Write-Log -Message &amp;quot;L&#039;utilisateur suivant est connecté à la console [$($CurrentConsoleUserSession.NTAccount)] (utilisateur avec le contrôle physique du moniteur, clavier et souris).&amp;quot; -Source $appDeployToolkitName
    
        $varserviceUI=&amp;quot;$scriptDirectory\_include\ServiceUIx64.exe&amp;quot;
        $var_FichierActionfinal=&amp;quot;msg.ps1&amp;quot;
        $Sdrive=&amp;quot;$env:systemdrive\&amp;quot;
        $Str_filetoLaunch=&amp;quot;$Sdrive$var_FichierActionfinal&amp;quot;
        $Str_Posh32=&amp;quot;$envWinDir\SysWOW64\WindowsPowerShell\v1.0\Powershell.exe&amp;quot;
        $Str_Posh64=&amp;quot;$envSystem32Directory\WindowsPowerShell\v1.0\Powershell.exe&amp;quot;
     
    
    $var_TexteFichierActionFinal = 
     @&#039;
           		
            [string]$scriptDirectory = &#039;Var_scriptDirectory&#039;
            [string]$moduleAppDeployToolkitMain = &amp;quot;$scriptDirectory\_Include\AppDeployToolkit\AppDeployToolkitMain.ps1&amp;quot;
            . $moduleAppDeployToolkitMain  
            	        
            Set-StrictMode -off
                Show-DialogBox -Title &#039;Installed Complete&#039; -Text &#039;Installation has completed. Please click OK and restart your computer.&#039; -Icon &#039;Information&#039;
            Set-StrictMode -Version Latest
    
    &#039;@
    
        Set-StrictMode -off
            If (test-path &amp;quot;$Str_filetoLaunch&amp;quot;) {Remove-File -Path &amp;quot;$Str_filetoLaunch&amp;quot;}
        Set-StrictMode -Version Latest
    
        New-Item -path &amp;quot;$Sdrive&amp;quot; -Name $var_FichierActionfinal -type file
        $var_TexteFichierActionFinal  | Out-File (Join-path -path $Sdrive -childpath $var_FichierActionfinal)
    
       (get-content $Str_filetoLaunch) | foreach-object {$_ -replace &#039;Var_scriptDirectory&#039;,&amp;quot;$scriptDirectory&amp;quot;} | set-content $Str_filetoLaunch
    
        #====================================
        #Lancement de la fenêtre
    
        Set-StrictMode -off
            Execute-Process -path &amp;quot;$varserviceUI&amp;quot; -Parameters &amp;quot;-process:explorer.exe $Str_Posh64 -File $Str_filetoLaunch -WindowStyle Hidden&amp;quot;
            If (test-path &amp;quot;$Str_filetoLaunch&amp;quot;) {Remove-File -Path &amp;quot;$Str_filetoLaunch&amp;quot;}  
        Set-StrictMode -Version Latest
    
        
    }</code>

    After running the first script, a second script will be create at the root of the C drive:

    <code>       ## Variables: Script
    		[string]$deployAppScriptFriendlyName = &#039;Deploy Application&#039;
    		[version]$deployAppScriptVersion = [version]&#039;3.8.0&#039;
    		[string]$deployAppScriptDate = &#039;11/03/2015&#039;
    		[hashtable]$deployAppScriptParameters = @{&amp;quot;DeploymentType&amp;quot; = &#039;install&#039;}
    
            [string]$scriptDirectory = &#039;E:\Temp\Test1.0_Frv1&#039;
    	    [string]$moduleAppDeployToolkitMain = &amp;quot;$scriptDirectory\_Include\AppDeployToolkit\AppDeployToolkitMain.ps1&amp;quot;
            . $moduleAppDeployToolkitMain  
           
            Set-StrictMode -off
                Show-DialogBox -Title &#039;Installed Complete&#039; -Text &#039;Installation has completed. Please click OK and restart your computer.&#039; -Icon &#039;Information&#039;
            Set-StrictMode -Version Latest
    
    </code>

    1. If I run the first script as an interactive session then I will get a Window
    2. If I run the first script Under the system account then the script will not be interactive and no window will show up. This is my problem

    If from my first script, I laucnch the second script with the following commandline:
    Execute-Process -path “$varserviceUI” -Parameters “-process:explorer.exe $Str_Posh64 -File $Str_filetoLaunch -WindowStyle Hidden”

    (or in clear E:\Temp\Test1.0_Frv1\_include\ServiceUIx64.exe -process:explorer.exe C:\WINDOWS\system32\WindowsPowerShell\v1.0\Powershell.exe -File C:\msg.ps1 -WindowStyle Hidden)

    Then it is working.

    So running with ServiceUI might be the solution. But the need to create a second file and running it with serviceUI is “bad”. Any other solution?

    Is it possible from Inside the script to detect if the session posh session is 32 or 64 bits?

    Thanks,

    • This reply was modified 1 year, 7 months ago by  Francois.
  • That_annoying_guy
    Participant
    Post count: 42

    RE: Is it possible from Inside the script to detect if the session posh session is 32 or 64 bits?
    $envOSArchitecture

    RE: I would like to show a w[i]ndows to ask the user to close his session with a[n] ok button. So I tried a Show-dialogbox but in the logs I am seeing a session 0 is active and then the Window is not showing.
    Show-InstallationPrompt

    RE: We are using the latest PSADTK 3.6.8
    3.6.8 is getting old. I don’t use it. I use this: https://github.com/PSAppDeployToolkit/PSAppDeployToolkit

    serviceUI might help you get around your “No GUI allowed in session 0” issue but it’s not well documented or officially supported. I’ve seen other posts about how to use it but I have never bothered to use it.

    • Francois
      Participant
      Post count: 105

      Hi,

      RE: Is it possible from Inside the script to detect if the session posh session is 32 or 64 bits?
      $envOSArchitecture

      But that variable would say the OS architecture not if the script is running in 32 or 64 bits mode?!

      RE: I would like to show a w[i]ndows to ask the user to close his session with a[n] ok button. So I tried a Show-dialogbox but in the logs I am seeing a session 0 is active and then the Window is not showing.
      Show-InstallationPrompt

      In what way Show-InstallationPrompt is better than Show-dialogbox?

      RE: We are using the latest PSADTK 3.6.8
      3.6.8 is getting old. I don’t use it. I use this: https://github.com/PSAppDeployToolkit/PSAppDeployToolkit

      But 3.6.8 is the official version isn’t it?

      serviceUI might help you get around your “No GUI allowed in session 0” issue but it’s not well documented or officially supported. I’ve seen other posts about how to use it but I have never bothered to use it.

      Was PSADTK suppose to support ServiceUI? A downside of service UI is you need to run the whole script with service UI. You cannot just load the PSADTK main script with serviceUI?!

      Thanks,

      François

  • Dan
    Participant
    Post count: 10

    I don’t think you are going to be able to run the program as hidden. And pop the box to have them close things.
    Your going to have to uncheck the box that says
    Suppress program notifications.

    Then you should be able to pop the box that forces applications closed.

    Dan

    • Francois
      Participant
      Post count: 105

      Hi,

      Showmessage was working on a test computer. On a VM it did not show up but it does on a physical one.

      Strange.

      Thanks,

  • Dan
    Participant
    Post count: 10

    First, run the powershell script all by itself on a test box. (not using SCCM at all.)
    Does the windows pop up? Or not?
    If not, you need the code to make the box pop up.
    This is pop up box I normally use.
    ## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
    Show-InstallationWelcome -CloseApps ‘iexplore’ -AllowDefer -DeferTimes 3 -CheckDiskSpace -PersistPrompt

    If the windows does show up.
    Then package it in SCCM and deploye it to your test box.
    Make sure the box next to
    Suppress program notifications
    IS NOT CHECKED>
    Run a deployment.
    Let me know your results.

    As far as your 64 bit/ 32 bit question. You can mark a package / Program to run on a specific platform.

    Dan

    • Francois
      Participant
      Post count: 105

      Hi,

      OK I review 3 computers. 2 of them switch to non interactive but one is interactive. That one, I was with a remote control on that computer. I just used the software center to start the setup. Not sure if it change anything.

      So the solution would be to create a file on c drive with PSADTK run the file with serviceUI and call the show… in that file. This is bad.

      On the PSADTK it is said to deploy only when a user is logged on to act interactively. This is not a good solution as many computers have no one logged on or if you wish to deploy at night.

      How does peoples handle this situation? Everyone using serviceUI in those situation? In what way does peoples are using serviceUI?

      Thanks,

      François

  • Francois
    Participant
    Post count: 105

    Hi Dan,

    It is an application not a package. By running the script myself manually, it is working correctly as expected.

    I deployed my script on VM and nothing showed up. Then I deployed on a physical computer and got everything.
    On my VM it does switch to non-interactive but on physical it was interactive.

    Very strange.

    Thanks,

  • Dan
    Participant
    Post count: 10

    Ok. If you have it working on one machine and not on another you have two avenues to go down.

    1. And this is what I would do first is check the log of the one that failed. So, get on the VM get into windows\logs\software. And sort by date. That should get you the logs in date order and find the powershell log from when you deployed. Then see if there is an error you can google.

    2. Expand what you have. If the log doesn’t give you anything, then you have to go with this as long as there wasn’t any damage from your first deploy you should be fine.
    Deploy it to another VM and see if you get a trend. Also see if you can get a test bed of physical machines and roll out to 5 or 10 of those. See how it goes and check through the logs for clues.

    • Francois
      Participant
      Post count: 105

      Hi,

      3 Computers with same applications. I believe the one who was interactive was because I was doing remote control on it. Then may be the sccm remote control is triggering the interactive mode. My further tests confirme the Show-InstallationPrompt is not working because the session 0. So I have to code Something using serviceUI64.

      My first test was to launch a posh script with psadtk. The result was interesting but there was the Posh window behind Show-InstallationPrompt and the PSADTK was showing behind. So I am looking to create somekind of exe and launching it with serviceUI.

      Thanks,

  • Dan
    Participant
    Post count: 10

    What are you trying to package?

    If I understand this correctly it has only worked on one machine. Right?

    So, go back to your test box and run the powershell script by itself and see of the box appears?
    I asusme we are taking about the Confirm box at the begginning of the Application Deployment Toolkit.

    does that sound like a plan?

    Or am I off base?

    Dan

    • Francois
      Participant
      Post count: 105

      Hi Dan,

      You are not so offbase 🙂
      I am trying to deploy an app on 3 computers.
      On my box, during the test, If I run the script manually from ISE, I get eerything correctly.

      In my code I don’t have so much window to display, Sometimes one to ask the customers to close some program because they may interfere and at the end a window asking the Customer to save his documents because SCCM will reboot the computer.

      WIth ISE it is sounding great. However in our SCCM test no Window was appearing at all. But we were pressing by time and we deployed on one Customer computer.

      So I connected with remote control (SCCM) open the software center and launch the installation. I was surprise to see all window appearing. We looked in the log and found the user was interactive.

      We deployed the apps to 2 other computers and no window appearing.

      On those 3 computers a Customer was log on.

      So the difference between computer 1 and computer 2 and 3 was… me on remove control. The SCCM settings was exactly the same. We are deploying the apps with any userstatus so we are not able to check the interactive session.

      Bck on my VM I made a test with the same SCCM settings and no window was appearing.

      So my conclusion is PSADTK is not bypassing session 0. So I will need to script Something using serviceUI.

      My first test with serviceUI was to create a second script by piping the good values and dot source PSADTK. It was great but the visual effect was bad. Behind Show-InstallationPrompt the Posh window was appearing and the PSADTK was appearing Inside…

      Thanks,

  • Dan
    Participant
    Post count: 10

    Ok. so, yeah, you are close.

    Get into your application and check to see if there is a program. (I never use applications so not sure if there is one, and don’t have the console here at home)
    But
    On a package/Program. there is a way to Suppress all windows. You may have that checked, so double check that inside SCCM console, on your program.

    If you run the PowerShell script and it works perfect. Then, you have to have a problem in the deploy or in the Application in the console. Because your script is correct if it works on it’s own locally.

    Also, if you are getting a partial screen, you might have your switch wrong after arguments.

    Is POSH the name of the application your are deploying?

  • Francois
    Participant
    Post count: 105

    Hi,

    No POsh stand for PowerShell 🙂
    In application there is that option too and we choosed to show Nothing to our customers. The main difference between Package and applications in this situations is in Package you can check Something to permit user to interact. In application, to check the samething you need to deploy only when a user is logon. This is bad. This is a problem as we want to have good result very fast and our user are shutting down their computers at night…. with no WOL.

    So the problem is the session 0 isolation. My last solution was to create an exe with Winbatch and pass my strings to this compile Winbatch and run it with serviceui. I will try it tuesday morning and I have very good hope.

    I don’t understand Why MS design that behavior differently than package. I believe interaction is not a nice to have and SCCM should handle it properly.

    Thanks,

  • Dan
    Participant
    Post count: 10

    Hopefully something of what I gave you helped.

You must be logged in to reply to this topic.