Date and Time on a file for different users

Really need help here with an Analyses. I’m trying to figure out how I get this analyses to run for different users. It’s the “%username%” thats screwing me up. Help, where am I going wrong? I need to generate reports for the suits this week. Someone please throw me a lifeline.

Thanks. see below

Sno

(modification time of it) of file “C:\users%username%\QnA\qna.exe”

I’m fairly certain that the client doesn’t know how to expand %username% in relevance, since this is an environment variable. They are dependent on the security context of the BES Client, which is LOCALSYSTEM in windows, not the context of the logged on user.

The client does know, however, about current user.

Try this:

(modification time of it as string) of file ("C:\users\" & name of current user & "\QnA\qna.exe)"

You might want to consider the case where the logged on user doesn’t have the file in question:

if (exists file ("C:\users\" & name of current user & "\QnA\qna.exe")) then (modification time of it as string) of file ("C:\users\" & name of current user & "\QnA\qna.exe") else ("File not found")

There’s probably a more elegant way to write this version, but it should work for you.

2 Likes

To add to @itsmpro92 method, you can actually expand environment variables and write the relevance using expressions the generate plural results to overcome cases where the file/folder/variable may not exist.

Q: modification times of files ((concatenation "" of values of variables "USERPROFILE" of environment) & "\QNA\qna.exe")
T: 0.339 ms
I: plural time

If this was written in to return a singular result, it would result in an singular expression error if the file/folder or variable does not exist.

Q: modification time of file ((value of variable "USERPROFILE" of environment) & "\QNA\qna.exe")
E: Singular expression refers to nonexistent object.
2 Likes

I should have been more specific here. I’m trying to figure out how I get this analyses to run for to capture the date and time of a file named qna.exe. It’s the “%username%” that’s screwing me up. Help, where am I going wrong? I need to generate reports for the suits this week. Someone please throw me a lifeline.

SPECIFICALLY WHAT I NEED IS TO CAPTURE THE DATE AND TIME STAMP OF QNA.EXE FOR DIFFERENT USERS. HOW DO i DO THIS? It’s the “%” that’s screwing everything up.

Below is what I came up with but it doesn’t work. Please help me, I need to generate some reports that are important.

Thanks,
Sno

(modification time of it) of file “C:\users%username%\QnA\qna.exe”

Unfortunately, it’s still not quite clear from the above precisely what you are trying to achieve. In particular, what is the (pseudo) logic you would like to use to identify the different users where you’d like to query the file details? Should it be:

  • currently logged on user?
  • all users that have logged on the device (and have a local profile)?
  • or something else?

I’m afraid that PUTTING IT IN ALL CAPS WON’T HELP. What we need is a more precise statement of the problem.

In case it’s not clear yet, %USERNAME% is a variable expansion in Windows’ CMD shell. It has no meaning at all in Relevance (nor would it have meaning in Python, or PowerShell, or Bash, or anything besides Windows’ CMD shell).

That said, what would you expect it to expand to? As Aram states, that’s a variable for the current user. If we had two accounts logged on to a server, each account would see a different value for USERNAME. We can guess the logged-on user in BigFix using something like current user or logged on users, but we’d get multiple results as each user may have a different version of the file in their directory.

Ignoring whether the user is logged-on or not, you could use this to list the file and version from each profile folder

(modification time of it, pathname of it) of files "QnA\qna.exe" of folders of folders "C:\users"

(assuming it’s directly beneath the user profile. You could amend that to something like “Desktop\QnA\qna.exe” if the file is somewhere else)

4 Likes

The currently logged on user is what I would need, that would help also. Simply put, the date and time stamp of a file on a computer. yes, It can be from the currently logged on person.

Many thanks.
Sno

@Snojack

for Currently Logged on User, you might try this relevance:

q: (pathname of it, modification time of it) of files "qna.exe" of folders "QnA" of folders (names of logged on users) of folders "C:\users"

1 Like

Many thanks to you all.