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?
Please log in to comment


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.
Please log in to comment
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

Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja