Page 1 of 1 1
Topic Options
#194694 - 2009-07-13 03:00 AM Login script issue
Kuroikenshi Offline
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.
 Code:
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.
 Code:
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 Administrator Online   shocked
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.

 Code:
? "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 Offline
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! \:D

EDIT: So I encorporated your code indo my script and made a few changes and voila! It works!... Here is the new script.

 Code:
$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 Offline
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
#194699 - 2009-07-13 09:02 AM Re: Login script issue [Re: Kuroikenshi]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
so, you don't have ability to use quotas?

to your issue, try this one and see for yourself:
 Code:
"testing integer limit"
?
$somevalue=cdbl("2148392960")


"testing if some value 2148392960 is larger when same"
?
if $somevalue>2148392960
 "larger"
else
 "not larger"
endif
? ?

"forcing test value to float/double"
?
"testing if some value is larger than 2148392960.0"
?
if $somevalue>2148392960.0
 "larger"
else
 "not larger"
endif

??


kixtart treats the value you input as integer and it's over integer limit and thus is not working... or something.
here is another quickie test to prove it:
 Code:
"testing integer limit"
?
$somevalue=cdbl("2148392960")
$someother=cdbl(2148392960)
?

vartypename($somevalue) " = " $somevalue
?
vartypename($someother) " = " $someother
?
vartypename(2148392960) " = " 2148392960

get $

_________________________
!

download KiXnet

Top
#195050 - 2009-07-27 05:04 AM Re: Login script issue [Re: Lonkero]
Kuroikenshi Offline
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 Offline
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
#195281 - 2009-08-05 10:18 PM Re: Login script issue [Re: freddie_26]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Please make a post in the Basic Scripting forum. You're "hijacking" a thread with an entirely different topic.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.057 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org