Jump to content
Welcome to our new Citrix community!
  • 0

run bat file or powershell after user logs in

John Litster


I have an applayer that after a user logs in, I would like a bat file or powershell run.    I have tried making a scedualled task run with the trigger of "when anybody logs in", but after finallizing and logging in, it isn't there anymore.


ANy ideas?

The reason being is that this app layer has Fiery Command Center and each time a user logs in, and starts it up, they would need to enter in the IP address of the printer and then log into it.

I found the files that get written when this info is entered, and I have tested that copying these files to the %appdata% directory after logging in and before starting the program, does work........

so I need these files copied after a person logs in.


How can I make this happen?


Thank you in advance.

Link to comment

17 answers to this question

Recommended Posts

  • 0

Thank you.....

so I changed the file extention of my bat file to be .cmd and verified it still worked.

made another version of my application so that the .cmd file will be there.

put the path the .cmd file in the Script Path


and tested again.



i verified the .cmd file is still where the script path shows.

is there a log anywhere so that I can see if the script actually ran and dont find it in the c:\program files\unidesk\uniservice\log\log0.txt file?




Link to comment
  • 0

I will try that as soon as I can.

I somehow broke my environment and can't get desktops to launch anymore.   I get the "cannot start desktop" message on the storefront webpage.   No event info in the event viewer on the DC, and the desktop just says 'initializing'

Once I get that part working again, I will try adding in the logging ability and get back to you here.

Link to comment
  • 0

Nope, it just sits there.     even let it sit over night.

I just remade the Platform layer and template.   Currently updating the Machine catalog with the new image.....

if it starts working after that, I should be able to the modify the script that started all this    ;)



well, updated the machine catalog, remade a delivery group and still the desktop sits at 'initializing'

I can lauch the remote console in vcenter and manaully log into the machine just fine (its powered on).   It isn't rebooting or anything.

I logged into it manaully via vcenter....the citrix ICA server isn't running.   I tried to start it, error 1067: the process terminated unexpectedly.


event log shows that it is talking to both of the delivery controllers I have without issue.

only error it reports is the ICA service issue with an event ID  7034


Link to comment
  • 0
On 4/22/2019 at 1:28 PM, John Litster said:

is there a log anywhere so that I can see if the script actually ran


If you're using a user layer, you can check C:\ProgramData\Unidesk\logs\ulayersvc.log. Search for the name of your script, and it'll show up as INFO 55 LayerConfigService: Execute script: C:\path\to\script.cmd returned #. The return code might provide some insight. 

Link to comment
  • 0

I guess you can close or whatever you do with threads that aren't going anywhere.

In re-creating the environment.....I still cannot get the machine to finish Initializing, thus I cannt get to see how the script is behaving.    Support got ahild of me, then promptly put me on terminal hold.


I give up.

Link to comment
  • 0

When I have an issue like that I first try a published image with just the os and platform layer to see if ti will boot correctly and register.  Aslo since you had it working before you could just try going back to the same layers and versions you used before and see what happens.  Then if the only issue is the layer you are trying to get the scripting to work with re-create that one.

Link to comment
  • 0

I have tried just opening the desktop without anything applied.    The desktop doesn't open.   on the DC is just sits at 'initalizing'.

I see there is an update for the applayer appliance.   I am currently updating that in hopes that creating this stuff works better.


Link to comment
  • 0

Finally some progress.

Ended up having to go back to my first OS layer for things to start installing properly again.....but anyway, back to the topic of this thread.....

I did put the logging in teh script like you suggested.   It does appear to be running.....




It is running before the user logs in.

the log should show

Dest : C:\Users\<users AD name>\AppData\Roaming\



it is showing this instead

Dest : C:\Windows\system32\config\systemprofile\AppData\Roaming\



it appears putting the script in the applayer script location causes it to run prior to the user logging in.

It needs to run after the users directoy is created.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...