Log off citrix session - citrix

I want to terminate a session hosted in xen app server. When i pass the following parameter to execute on command line such as
/username:TestUser /domain:TestDomina /password:xxxxyyyz /cmdline:logoff using shell api ?
The wfc command line usgae pop up comes up. DOes it mean that we cannot log off using the command line option in wfc ?
Thanks

To logoff the current session from the app the user is running you can use the following.
WTSLogoffSession(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, false)
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383836%28v=vs.85%29.aspx

Related

Connect to an existing session in Powershell by its id

For a really specific use, i need to connect to an existing session which have a opened desktop (with gui). To maintain the gui, we opened the session with rdp and already use a powershell script which transform the rdp session into a console session (without exiting gui since the session technicaly stay open).
Before, I used psexec with the -i parameter set (I got the session's Id by the username) but now, I'm trying to do the same with pure powershell.
Any thought?

zlogin usage in Runeck task

As part of rundeck task i'm trying to login to a global zone, use the command zoneadm list and trying to login to each of the local zone [to shut down various apps & to issue reboot] using the command /usr/sbin/zlogin and execute hostname command to ensure it did login to localzone
however this is not working
Is there a better way to do this? Please guide
Make sure that your job is dispatching to your remote node correctly, you can call the command on "Commands" (right panel) pointing to your node (referenced in the "Nodes" textbox) in that way you can discard possible path/user rights issue, take a look at this. Now, zlogin seems an interactive shell, and as you can see, you need to use it in the non-interactive mode.

A user can close a script running by killing powershell task

How can I prevent a user from killing powershell process which ends the action of the script. and how can I restart powershell by a piece of code to resume its action?
If the script is being run under the users account, you can't stop them from being able to kill the process.
To get around this, you could have the script run as another user (as a service, or invoking as another user) which will launch the Powershell session under their credentials, in which case only admins will be able to kill the process.
Speaking from experience here:
In our environment we run SCCM, we have several powershell scripts that open a verbose window to let the user know that something is running. This script is running as SYSTEM. The user can still close the window even if they're not a member of the administrators group.
To get around crucial scripts that can't be closed I would suggest running the script silently, so that way it runs without the user even knowing. Or, if you indeed need a GUI, use VB.NET / C# to create a form and use the form closing event to prevent the user from closing it until you're well and ready.

Powershell how to run a program and waiting in a remote session

I have a command line program that listen to a tcp port until user type Q to exist. It works fine in local powershell window. But when I try to run it on another machine using powershell remote session, it just starts and quit. Is there a way to keep it running?
The remote script runs in a PowerShell that never becomes visible so AFAICT it doesn't even got a console handle by which to handle reading keyboard input.
You can take a look at the SysInternals utility - psexec. From my testing, that utility works for what you are trying to do.
Ensure you have Powershell 3 or higher since it adds support for detached sessions/background jobs.
Use a Remote Disconnected Session, described on Technet

How can I start XServer in Linux through apache user triggered by Perl script running in background?

I am trying to launch MS Office through WINE using a Perl script hosted by apache
and and triggered by other application. I am getting the following error message in
log files "Application trying to create a window but no driver could not be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly".
If I run the script directly on shell prompt using root user then WINE starts
XServer properly and execute MS MSoffice in addition to that if I set xhost +local:apache on shell prompt then also it works fine.
How can I start the XServer from apache user?
It is an exceedingly bad idea to start a X server per httpd worker. If you insist on doing this though, use Xvfb.
My recommendation would be to have a separate daemon handle the document conversion/creation, and use a message queue to pass it jobs.