Scripting Question

trying to remove / see if a specific file from users desktops

12/14/2015 1974 views
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


  • I made a further test...
    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
  • I am having same problem...any update on how to resolve?

All Answers

How about using %USERPROFILE%\Desktop instead of c:\users\%username%\desktop ?
Answered 03/21/2017 by: JasonEgg
Red Belt

These settings worked for me:

If you're still having problems, consider posting the XML of your current kscript (click on the "Edit XML" button, right above the "Dependencies" heading)
Answered 03/21/2017 by: JasonEgg
Red Belt

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.
Answered 12/15/2015 by: CraigT
Orange Belt

  • I have the option to run as Logged-in user checked.
  • This is only evident with 6.4 agents, works fine on 6.0 agent machines.
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.

Answered 05/11/2016 by: chucksteel
Red Belt

  • 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!
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ