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?
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)
Please log in to answer
Posted by:
GillySpy
12 years ago
Posted by:
dchristian
12 years ago
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:
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:
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.