I am tasked with creating a Custom Inventory rule that will do the following:

1. Get total file count and total file size (MB) from two different directories on all Windows machines - The first is a directory called C:\RealTimeBackup. The 2nd is the current logged on user's My Documents folder. This needs to be run at every Inventory check-in

2. Output the data from step 1 to a text file

3. Upload the data from the text file in step 2 to the KBox for each machine

I am able to get steps 2 and 3 working fine for the most part. They would be fine if I can solve the problem I have run into with step 1. I can use the diruse.exe command (diruse.exe /M %USERPROFILE%\Documents C:\RealTimeBackup) to get the info I need when I run it in a batch file locally on a machine. The problem is with running it as a Custom Inventory rule since the Inventory check runs under the SYSTEM account.

My question is, how can I change this around so it will give me the details of the logged in user's Documents folder instead of the SYSTEM account's documents?
0 Comments   [ - ] Hide Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity


you could use a script like this and put the contents into a reg key which the CI reads.
Answered 03/06/2012 by: GillySpy
Seventh Degree Black Belt

Please log in to comment
Alright jayp2200,

I think this will do what you need.

I created a new shell script.

Then i uploaded diruse.exe as a dependency.

Here's what i put in for the script text:
@echo off
if not exist c:\windows\tvg mkdir c:\windows\tvg\
if exist c:\windows\tvg\Sizer.txt del c:\windows\tvg\Sizer.txt

date /t >> c:\windows\tvg\Sizer.txt
time /t >> c:\windows\tvg\Sizer.txt

if exist C:\users (
for /f %%a in ('dir /b "C:\users\"') do diruse.exe /M "c:\users\%%a\documents" | find " TOTAL:" >> c:\windows\tvg\Sizer.txt

if not EXIST C:\users (
for /f %%b in ('dir /b "c:\Documents and Settings\"') do diruse.exe /M "c:\Documents and Settings\%%b\My Documents" | find " TOTAL:" >> c:\windows\tvg\Sizer.txt

IF EXIST C:\RealTimeBackup (
diruse.exe /M C:\RealTimeBackup | find " TOTAL:" >> c:\windows\tvg\Sizer.txt

Remember to change the script name from script.sh to script.bat.

I'll let you work out the machines and the schedule.

You can tie the info back to the kbox with a custom inventory rule.

Here's the syntax:
ShellCommandTextReturn(cmd.exe /c type c:\windows\tvg\Sizer.txt )
Answered 03/06/2012 by: dchristian
Red Belt

Please log in to comment
Thanks guys for the great suggestions. I will try them as soon as I get a chance.
Answered 03/08/2012 by: jayp2200
Senior Yellow Belt

Please log in to comment