active8it
asked on
citrix logoff script pass back to local pc
does anyone know of a way to run a shutdown sequence on the local pc when logging off a citrix xenapp full desktop session? i.e. so if a user logs off citrix full published desktop it will shutdown the windows 7 pc they are locally using.
Check the following similar thread (instead of logging off you will have to modify the script to shut down):
https://www.experts-exchange.com/questions/27591958/Force-windows-log-off-when-Citrix-ICA-client-closes.html
https://www.experts-exchange.com/questions/27591958/Force-windows-log-off-when-Citrix-ICA-client-closes.html
you can also add reason & comments for your shutdown.
shutdown -s -t 120 -d P:00:00 -c "Citrix Session Log off and Guest PC Shutdown Script"
shutdown -s -t 120 -d P:00:00 -c "Citrix Session Log off and Guest PC Shutdown Script"
Mutawadi: Thread already been posted.Please read/refresh before posting.
ASKER
issue i have is i dont think mine is the same as using a login script that runs the followign to launch a full desktop straight off.
"C:\Program Files\Citrix\ICA Client\pnagent.exe" /CitrixShortcut: (1) /QLaunch "xenapp:Full Desktop"
is there a way a could modify yours to work with this
"C:\Program Files\Citrix\ICA Client\pnagent.exe" /CitrixShortcut: (1) /QLaunch "xenapp:Full Desktop"
is there a way a could modify yours to work with this
You could also create a powershell script (you mentioned Windows 7 in the tags) to monitor the process and invoke an action when it ends.
start-sleep -seconds 15
$Process="PNAgent"
$proc = Get-Process | Where-Object {$_.ProcessName -eq $Process}
while ($true)
{
while (!($process))
{
$proc = Get-Process | Where-Object {$_.ProcessName -eq $Process}
start-sleep -seconds 5
}
if ($proc)
{
$proc.WaitForExit()
start-sleep -seconds 5
$proc = Get-Process | Where-Object {$_.ProcessName -eq $Process}
$wsh = New-Object -ComObject wscript.shell
write-host "Shutting down local PC in 10 seconds"
$Shutdown = "shutdown.exe -s -t 10"
$wsh.run $shutdown
}
}
Save it as a .PS1 file (you will have to invoke powershell executionpolicy to run all) and invoke it in a login script on the local PC
i.e. create a simple batch file that contains:
c:\windows\system32\window spowershel l\v1.0\pow ershell.ex e -executionpolicy unrestricted scriptname.ps1
Assuming you called the above scriptname.ps1
There is a 15 second delay at the start to ensure the PNAgent process has time to start (you could put it in the same login script just to be sure) and the script pauses for 5s per loop.
start-sleep -seconds 15
$Process="PNAgent"
$proc = Get-Process | Where-Object {$_.ProcessName -eq $Process}
while ($true)
{
while (!($process))
{
$proc = Get-Process | Where-Object {$_.ProcessName -eq $Process}
start-sleep -seconds 5
}
if ($proc)
{
$proc.WaitForExit()
start-sleep -seconds 5
$proc = Get-Process | Where-Object {$_.ProcessName -eq $Process}
$wsh = New-Object -ComObject wscript.shell
write-host "Shutting down local PC in 10 seconds"
$Shutdown = "shutdown.exe -s -t 10"
$wsh.run $shutdown
}
}
Save it as a .PS1 file (you will have to invoke powershell executionpolicy to run all) and invoke it in a login script on the local PC
i.e. create a simple batch file that contains:
c:\windows\system32\window
Assuming you called the above scriptname.ps1
There is a 15 second delay at the start to ensure the PNAgent process has time to start (you could put it in the same login script just to be sure) and the script pauses for 5s per loop.
You could use the system variable called clientname to shut the local computer down from the Citrix servers logoff script.
shutdown \\%clientname% /t:120 "Computer is shutting down" /y /c
//Kent
shutdown \\%clientname% /t:120 "Computer is shutting down" /y /c
//Kent
Yeah but that won't work if there's a CAG/WI server as it gets obfuscated.
ASKER
yes it has a webinterface
If it is a must to let the Web Interface change the names, and it is done for some reason - Citrix policies for example - then I agree, but you could configure web interface to not changing the client names, if that would fit your existing demands.
//Kent.
//Kent.
And preventing WI from changing the name has a nasty side effect in that it tends to break other things such as session reconnect and workspace control.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And Coralon's script has the added advantage of being in VBScript which means it'll run natively on Windows XP.
https://www.experts-exchange.com/questions/27591958/Force-windows-log-off-when-Citrix-ICA-client-closes.html
you will have to modify script to shutdown i.e.
"shutdown -s -t 00 -f"
this shutdown your PC.