Value of variable "AppData" not working

(imported topic written by cstoneba)

Any thoughts as to why this command fails?

waithidden cmd.exe /C rmdir /Q /S “{(value of variable “AppData” of environment) & “\Citrix\PNagent”}”

Command failed (Relevance substitution failed) waithidden cmd.exe /C rmdir /Q /S “{(value of variable “AppData” of environment) & “\Citrix\PNagent”}” (fixlet 2495)

Also, what happens if a user is not logged on?

(imported comment written by NoahSalzman)

You might try moving the parentheses, it worked for me that way:

waithidden cmd.exe /C rmdir /Q /S “{(value of variable “AppData” of environment & “\Citrix\PNagent”)}”

You might want to use “exists current user” as part of the gating relevance if you want to ensure that the a user is logged on.

(imported comment written by cstoneba)

I’m still get an error:

Command failed (Relevance substitution failed) waithidden cmd.exe /C rmdir /Q /S “{(value of variable “AppData” of environment & “\Citrix\PNagent”)}” (fixlet 2516)

(imported comment written by NoahSalzman)

What does

value of variable “AppData” of environment

do on its own outside of the actionscript? That is, does it return a value or an error?

(imported comment written by jessewk)

Remember that the client runs this command as the SYSTEM user. I don’t think the SYSTEM user will have an “AppData” environment variable.

You can modify your action script to do this:

waithidden cmd.exe /C rmdir /Q /S “{value “APPDATA” of key “Volatile Environment” of current user key (logged on user) of registry}\Citrix\PNagent”

You should also add the following to the relevance of the action to prevent failures if there are no logged on users or more than one logged on user:

number of logged on users = 1

Jesse

(imported comment written by cstoneba)

That works great. Thanks Jesse. My concern now is that I still want to delete the %appdata%\Citrix\PNAgent folder, even if no one is logged on (and delete the folder in all the profiles). Currently researching that one but any input would be helpful.

(imported comment written by cstoneba)

Woot, I am now an “experienced member”. Well, a member none the less…

(imported comment written by cstoneba)

Got it to work with this command:

waithidden cmd.exe /C for /f “usebackq” %a in (dir /b /a "c:\documents and settings") do rd /s /q “c:\documents and Settings%a\Application Data\Citrix\PNAgent”

(imported comment written by cstoneba)

When I try and runn the following command (a variant of the commands mentioned in higher threads), it fails because it is reading the “All Users” folder as just “All”. When I manually run the following command from command prompt, it cannot find the path.

action:

for /f “usebackq” %a in (dir /b /a "c:\documents and settings") do del /f /q “c:\documents and Settings%a\Start Menu\Programs\Startup\Program Neighborhood Agent.lnk”

error:

del /f /q “c:\documents and Settings\All\Start Menu\Programs\Startup\Program Neighborhood Agent.lnk”

The system cannot find the path specified.

(imported comment written by jessewk)

try this:

for /f “usebackq tokens=*” %a in (dir /b /a "c:\documents and settings") do del /f /q “c:\documents and Settings%a\Start Menu\Programs\Startup\Program Neighborhood Agent.lnk”

(imported comment written by cstoneba)

Works like a charm. thanks jessewk!