[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

citrix logoff script pass back to local pc

Posted on 2012-08-16
13
Medium Priority
?
1,852 Views
Last Modified: 2012-08-24
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.
0
Comment
Question by:active8it
  • 4
  • 3
  • 2
  • +3
13 Comments
 
LVL 7

Expert Comment

by:mayureshtodankar
ID: 38299895
You can try this thread

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_27591958.html

you will have to modify script to shutdown i.e.

"shutdown -s -t 00 -f"

this shutdown your PC.
0
 
LVL 23

Expert Comment

by:Ayman Bakr
ID: 38299902
Check the following similar thread (instead of logging off you will have to modify the script to shut down):

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_27591958.html
0
 
LVL 7

Expert Comment

by:mayureshtodankar
ID: 38299908
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"
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 7

Expert Comment

by:mayureshtodankar
ID: 38299912
Mutawadi: Thread already been posted.Please read/refresh before posting.
0
 
LVL 2

Author Comment

by:active8it
ID: 38299914
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
0
 
LVL 26

Expert Comment

by:Tony J
ID: 38300339
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\windowspowershell\v1.0\powershell.exe -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.
0
 
LVL 6

Expert Comment

by:Kentrix70
ID: 38302656
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
0
 
LVL 26

Expert Comment

by:Tony J
ID: 38302764
Yeah but that won't work if there's a CAG/WI server as it gets obfuscated.
0
 
LVL 2

Author Comment

by:active8it
ID: 38303854
yes it has a webinterface
0
 
LVL 6

Expert Comment

by:Kentrix70
ID: 38303927
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.
0
 
LVL 26

Expert Comment

by:Tony J
ID: 38303945
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.
0
 
LVL 25

Accepted Solution

by:
Coralon earned 1500 total points
ID: 38308157
Montoring this from the client side is by far the easiest way to do this.  It is similar to what Tony1044 has posted above.

option explicit
dim bFirstResults, bLaterResults, wshShell
dim oWMI, colProcesses

bFirstResults = vbTrue
bLaterResults = vbFalse

Do Until bFirstResults = vbTrue
wscript.sleep(10000)
bFirstResults = FirstPass()
Loop

Do
wscript.sleep(10000)
bLaterResults = LaterPass()
Loop Until bLaterResults = vbFalse

set wshShell = CreateObject ("wscript.shell")
wshShell.Run "shutdown.exe /s /t 5", 0, vbFalse

Function FirstPass()
set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
set colProcesses = oWMI.ExecQuery  ("SELECT * FROM Win32_Process WHERE Name = wfica32.exe")
if colProcesses.Count = 0 then
bFirstResults = vbFalse
else
bFirstResults = vbTrue
end if
FirstPass = bFirstResults
end function

Function LaterPass()
set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
set colProcesses = oWMI.ExecQuery  ("SELECT * FROM Win32_Process WHERE Name = wfica32.exe")
if colProcesses.Count = 0 then
bLaterResults = vbFalse
else
bLaterResults = vbTrue
end if
LaterPass = bFirstResults
end function

Open in new window


This isn't completely tested yet.  You basically assign this as a login script for the user on the client side device.  It checks to see if wfica32.exe is running (which is the runtime for a live connection).  It keeps checking until it sees it (first pass).

Then, once it has seen it, it starts the LaterPass watching for the exe.  When it doesn't find it, it shuts the system down.  The only caveat is LaterPass is running on a 10 second pass, but the sleep cycle can be adjusted.

Coralon
0
 
LVL 26

Expert Comment

by:Tony J
ID: 38308275
And Coralon's script has the added advantage of being in VBScript which means it'll run natively on Windows XP.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question