#194694 - 2009-07-13 03:00 AM
Login script issue
|
Kuroikenshi
Just in Town
Registered: 2009-04-15
Posts: 4
Loc: Japan
|
Hello all! I gathered a kixtart script from this site that was able to give a person a size of a folder in bytes. I had then modified it to do this to a network share, namely a persons home drive that each person has on our server. We are also using version 4.23 of kixtart and With that...
The following code is the portion that I got from these forum's. Only thing I added was the "IF NOT EXIST" statement.
IF NOT EXIST ("%Userprofile%\FolderOver.txt") OR NOT EXIST ("%Userprofile%\FolderUnder.txt")
$Directory = "\\SERVERNAME\DIRECTORY\%Username%\"
$DirSize = fnGetFolderProp($Directory,Size)
$DirSizeKB = $DirSize / 1024
$DirSizeMB = $DirSizeKB / 1024
$DirSizeGB = $DirSizeMB / 1024
Function fnGetFolderProp($sFldr,$sProp)
Dim $objFSO, $objFldr, $nul
$objFSO = CreateObject("Scripting.FileSystemObject")
If Not VarType($objFSO)=9 Exit 1 EndIf
$objFldr = $objFSO.GetFolder($sFldr)
If Not VarType($objFldr)=9 Exit 3 EndIf
$nul=Execute("$$fnGetFolderProp = $$objFldr."+$sProp)
If VarType($fnGetFolderProp)=0 Exit 87 EndIf
EndFunction
This portion is where I wanted to take the total size of it and use a > and < then. I calculated the size and this should be the 2GB mark. Although when I test this using my account, it says that I am over the limit but home folder is well under the amount. I am thinking that it is something very simple but I can't really see what or where the problem is.
IF $DirSize > 2148392960 AND EXIST ("\\SERVERNAME\DIRECTORY\%Username%.txt")
$msg = MessageBox('Your H drive is over the acceptable limit. Please delete all non essential work from there. You will continue to get this warning until it is done.','WARNING',16+4096)
EndIF
IF $DirSize > 2148392960 AND NOT EXIST ("\\SERVERNAME\DIRECTORY\%Username%.txt")
$msg = MessageBox('Your H drive is over the acceptable limit. Please delete all non essential work from there. You will continue to get this warning until it is done.','WARNING',16+4096)
RedirectOutput("\\SERVERNAME\DIRECTORY\%Username%.txt", overwrite)
EndIF
IF $DirSize < 2148392960 AND EXIST ("\\Kehs3\express\Server Space Analysis\Teachers\%Username%.txt")
DEL "\\SERVERNAME\DIRECTORY\%Username%.txt"
EndIF
I would appreciate any help so that I could learn from my mistake here, thanks once again for any help that you could provide.
Edited by Kuroikenshi (2009-07-13 03:01 AM)
|
Top
|
|
|
|
#194695 - 2009-07-13 04:32 AM
Re: Login script issue
[Re: Kuroikenshi]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Not to ask a dumb question, but why the txt files?
In your first section of code... you are missing an endif, and be careful of the "OR Not". It's probably "And Not" you want. I always have to do a double take when I see those.
Untested code, and commented areas where you need to make changes or deletes. Make sure you are seeing a value displayed to the screen, because its possible the value is not what you are expecting.
? "dirSize=" + $dirsize
$userfile="\\SERVERNAME\DIRECTORY\%Username%.txt")
if $dirsize>2148392960
if not exist($userfile)
;write the userfile
endif
else
if exist($userfile)
;del $userfile
endif
endif
|
Top
|
|
|
|
#194696 - 2009-07-13 04:42 AM
Re: Login script issue
[Re: Allen]
|
Kuroikenshi
Just in Town
Registered: 2009-04-15
Posts: 4
Loc: Japan
|
The reason for the text file is that I want to see who's home directory is over the limit. So if their directory folder is over, it will make a simple text file with their username so I can keep track of them.
I will go ahead and use that code you typed up. Thanks for the reply!
EDIT: So I encorporated your code indo my script and made a few changes and voila! It works!... Here is the new script.
$Directory = "\\SERVER\DIRECTORY\%Username%\"
$DirSize = fnGetFolderProp($Directory,Size)
$DirSizeKB = $DirSize / 1024
$DirSizeMB = $DirSizeKB / 1024
$DirSizeGB = $DirSizeMB / 1024
Function fnGetFolderProp($sFldr,$sProp)
Dim $objFSO, $objFldr, $nul
$objFSO = CreateObject("Scripting.FileSystemObject")
If Not VarType($objFSO)=9 Exit 1 EndIf
$objFldr = $objFSO.GetFolder($sFldr)
If Not VarType($objFldr)=9 Exit 3 EndIf
$nul=Execute("$$fnGetFolderProp = $$objFldr."+$sProp)
If VarType($fnGetFolderProp)=0 Exit 87 EndIf
EndFunction
? "dirSize=" + $dirsize
$userfile="\\SERVER\DIRECTORY\%Username%.txt"
IF $dirsize>2148392960 AND NOT EXIST($userfile)
$msg = MessageBox('Your H drive is over the acceptable limit. Please delete all non essential work from there. You will continue to get this warning until it is done.','WARNING',16+4096)
RedirectOutput("$userfile", overwrite)
EndIf
IF $dirsize>2148392960 AND EXIST($userfile)
DEL $userfile
EndIf
Also made changes into my main script that may have contributed to the problem. Thanks once again for the help!
Edited by Kuroikenshi (2009-07-13 05:33 AM)
|
Top
|
|
|
|
#194698 - 2009-07-13 08:28 AM
Re: Login script issue
[Re: Kuroikenshi]
|
Kuroikenshi
Just in Town
Registered: 2009-04-15
Posts: 4
Loc: Japan
|
Well this is strange... the script worked fine a few minutes ago but now I am getting the false positives again and its really weird.
After I put in the new code I tested it out on my domain and it worked fine. The user-file text was deleted from the appropriate directory and everything was dandy. Now when I login it it says that I am over the limit but I am not.
Going to try to retrace my steps with what I did but I didn't really do anything.
|
Top
|
|
|
|
#195050 - 2009-07-27 05:04 AM
Re: Login script issue
[Re: Lonkero]
|
Kuroikenshi
Just in Town
Registered: 2009-04-15
Posts: 4
Loc: Japan
|
Sorry for the wait. I was on vacation and yes it was because of the limit. I changed the number to something a little lower and it worked out fine. Thanks again!
|
Top
|
|
|
|
#195280 - 2009-08-05 10:02 PM
Re: Login script issue
[Re: Kuroikenshi]
|
freddie_26
Fresh Scripter
Registered: 2009-08-05
Posts: 11
Loc: Canada
|
Can someone tell me what is wron with this part of my script
If INGROUP("Toronto) use J: \\cotommp\RHH Use z: \\10.10.10.1\HR /user:grp /password:map EndIF
The first drive maps but not the second....Why
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
2 registered
(morganw, mole)
and 414 anonymous users online.
|
|
|