Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Disk Quota Notifications (Using Script) Not Working

Posted on 2008-10-30
6
2,779 Views
Last Modified: 2013-12-02
I am pulling my hair out on this one.  I am trying to set up disk notifications using a simple .vbs script I have written that simply pops up a message box.  I cannot, for the life of me, figure out how to get this working within the quota template (in file system resource manager).  E-mail notification works fine, but I do not want to use that.

I need to know:

1 - What to put in the "Run this command or script" field
2 - What to put in the "Command arguments" field
3 - What to choose for the working directory
4 - What permissions to use on these folders
5 - Which command security option I should choose (I would rather go with most secure)

I found somewhere online that I should put "%windir%\system32\cscript.exe" in the "Run this command or script field, and "//nologo C:\Admin\nameofmyvbsscript.vbs" in the "Command arguments" field.  DOESN'T WORK.  What am I doing wrong?

All I want to do is have my vbs execute on the user's machine when they exceed the warning limit.  Seems easy, but no!  Thanks in advance for any help.
0
Comment
Question by:mtsi
  • 3
  • 3
6 Comments
 
LVL 31

Expert Comment

by:Henrik Johansson
ID: 22857623
You nead to run the quota-notification on the file server instead of at the client workstation. Let the result of the script execute a 'net send' targetting the user.
0
 

Author Comment

by:mtsi
ID: 22867362
Yes, I've tried that as well, and could not get it to work.  But that still doesn't answer the question.  Even if I wanted the script to do a net send, I can't get it to execute.  I've even tried a batch file and that doesn't work.  I need more details about how I can get the script to work (with any command).  The command is irrelevant at this point.  I just want the script to run.  Thanks.
0
 
LVL 31

Expert Comment

by:Henrik Johansson
ID: 22881755
The below sample is a working quota configuration file.

Notification=C
RunLimitInterval=1
Command=C:\WINDOWS\SYSTEM32\cmd.exe
Arguments=/c C:\quota-notify.cmd [Source IO Owner] [Quota Path] [Quota Threshold] [Quota Limit]
LogResult=Enable
Account=LocalSystem
WorkingDirectory=c:\temp
MonitorCommand=Enable
KillTimeout=5
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:mtsi
ID: 22890192
Great, thanks for the response.  A few more questions:

1 - I have no idea what path the actual quota configuration file is located at.  I know where to edit some of those things within the GUI configurator, but not the file.  Please let me know.
2 - What are the contents of your "quota-notify.cmd" file in this example?
3 - Do I have to run it as LocalSystem?  I would rather avoid that if possible, and run it as LocalService instead.

Thanks again for your help.
0
 
LVL 31

Accepted Solution

by:
Henrik Johansson earned 500 total points
ID: 22896087
1. The configuration file is just a textfile used for importing configuration with dirquota CLI-tool.
C:\>dirquota quota add /path:path-to-folder /add-notification:80,C,c:\quota-notify.cfg
C:\>dirquota quota modify /path:path-to-folder /modify-notification:80,C,c:\quota-notify.cfg

If you prefer GUI-based management, the management dialog should look like the attached printscreen.

2. Handle %~1 %~2 etc for each counted parameter (%1 works also, but will not handle "spaced argument" as a single argument). First line splits out USERNAME from  DOMAIN\USERNAME. The script is only logging to a text file, but can also use msg command (replaces 'net send') to send an alert.

for /F "delims=\ tokens=2" %%a in ("%~1") do set quotauser=%%a
echo %DATE% %TIME% %quotauser% passed %~2 percent of %~3 in %~4 >> c:\temp\quota-notify.txt

3. Yes, you shall be able to run it as LocalService instead of LocalSystem. I just used LocalSystem in a lab environment
quota-mgmt.jpg
0
 

Author Comment

by:mtsi
ID: 22932028
Just for those that might be in the same boat...

I was never able to get the .cmd file working, although I'm sure it's possible.  Instead, I used a .vbs script to run a net send command.  Here were the commands I used in FSRM for the template I was setting up:

Run this command or script:

C:\Windows\System32\cscript.exe

Command arguments (note that [Source Io Owner] is very important cause the vbscript uses that to find the current user and send them a message):

//nologo "FULL PATH TO YOUR SCRIPT" [Source Io Owner] [Quota Limit MB] [Whatever other args you want from FSRM]

Working directory:

Same as FULL PATH TO YOUR SCRIPT, minus the script name and last backslash

Run the command as:

LocalService

Here are the contents are my .vbs script:

'*******************************

'Turn on error checking
On Error Resume Next

'Declare variables
Dim objShell
Dim strUser
Dim strLimitMB
Dim intSlashPos

'Get arguments that were passed to the script through File System Resource Manager.  
'You can modify this based on how many arguments you want to give the script in the
'"Command Arguments" field
strUser = WScript.Arguments.Item(0)
strLimitMB = WScript.Arguments.Item(1)

'Remove the "DOMAIN\" portion from the user name
intSlashPos = Instr (1, strUser, "\", vbTextCompare)
strUser = Mid (strUser, intSlashPos + 1, Len(strUser) - intSlashPos)

'Create the object
Set objShell = Wscript.CreateObject("WScript.Shell")

'Create the message to send - this relies on arguments that were passed
'from File System Resource Manager
strMessage = "Some message here.  For example, your folder has reached the limit of " & _
                       strLimitMB & " MB."

'Send the message to the user
objShell.Run "net send " & [strUser] & " " & [strMessage], True

WScript.Quit

******************

I hope this helps others, cause I know how frustrating this is...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question