trying to remove / see if a specific file from users desktops
tried to make a Online Kscript to verify a file exist.
Run as Logged-in user
Verify a file exisits
Directory: c:\users\%username%\desktop
File: FILENAME.EXE
in the status log I get:
File does not exist: c:\users\comp-123$\desktop\FILENAME.EXE
instead of the logged in username i am getting the computer name with a $.
Should %username% work?
2 Comments
[ + ] Show comments
Answers (4)
Please log in to answer
Posted by:
JasonEgg
7 years ago
Posted by:
JasonEgg
7 years ago
Posted by:
CraigT
8 years ago
If you are getting the desktop name instead of the actual username it means that the action is being executed as SYSTEM instead of the logged in user.
Comments:
-
I have the option to run as Logged-in user checked. - kroosevelt 8 years ago
-
This is only evident with 6.4 agents, works fine on 6.0 agent machines. - bnerison 7 years ago
Posted by:
chucksteel
8 years ago
I have had issues in the past with getting KACE to run as the logged in user. You could use this command to get the current logged in user:
for /f "tokens=8" %%a in ('tasklist /v ^|find "explorer.exe"') do (
set "user=%%a")
That will set the user variable to the current user and you can use that to delete the file. You would use this in a shell script, not a KScript.
Comments:
-
I tried this shell script but get error - Run As Console Logged in user failed: No User logged in to console however I am logged into the machine I am running it on. Please help, thanks! - bnerison 7 years ago
I added a step to execute the following batch
SET > Myfile.txt
The interesting fact is that it seems that the Verify File action is impersonating the computer account while the Execute Batch in the remediation phase is impersonating the right user (all the environment variables were right there).
I will investigate a bit more....
Kind regards,
Marco - StockTrader - StockTrader 8 years ago