/build/static/layout/Breadcrumb_cap_w.png

Custom Inventory Rule - Upload Doc Count

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   [ + ] Show comments

Answers (3)

Posted by: GillySpy 12 years ago
7th Degree Black Belt
0
you could use a script like this and put the contents into a reg key which the CI reads.
http://www.kace.com/support/kb/index.php?action=artikel&cat=5&id=698&artlang=en
Posted by: dchristian 12 years ago
Red Belt
0
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 )
Posted by: jayp2200 12 years ago
Senior Yellow Belt
0
Thanks guys for the great suggestions. I will try them as soon as I get a chance.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
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