Scripts Thread, vb script to check filesize and copy file not eq... in Coding and Web Development; Hi, Following on from my exploration into trying to get Word to close down all the toolbars and only use ...
1. ## vb script to check filesize and copy file not eq...

Hi,

Following on from my exploration into trying to get Word to close down all the toolbars and only use some custom ones for all users I've found that I can use AutoExec in the normal.dot to run a Macro that does it all for me.

Bit hacked I know but my problem now is that I want to be able to the login script to run a quick check that the normal.dot, the user logging-in, has in their profile/application data/microsoft/templates folder is the correct size (ie: it's my customised version) and then copy a default normal.dot across if it has changed at all.

The layout is such that:

is the default profile folder...

I'm already using VB in my current login script and I'm trying to learn so any input at this point would be appreciated.

Cheers

Martin

2. ## Re: vb script to check filesize and copy file not eq...

Oh and if anyone has a seriously "genius" / masochism hat on then I'd also be interested in being able to check if a user is in a specific OU and apply or not accordingly.

Probably something I've seen already but just thinking ahead as I suspect staff may want to retain their Word toolbar settings...

3. ## Re: vb script to check filesize and copy file not eq...

Code:
Dim filesys, oFile, fSize
Set filesys = CreateObject("Scripting.FileSystemObject")
Set oFile = filesys.GetFile("c:\text.txt")
fSize = oFile.size
if fSize <> 24 then
msgbox "File Changed"
else
msgbox "File not changed"
end if
set filesys = nothing
Will check the size of the file in bytes and if it's more or less than it should be you can change the "File Changed" msgbox to be code to copy your new file.

Ben

4. ## Re: vb script to check filesize and copy file not eq...

Genius / Masochist tag? gimme, gimme, gimme!

Easy really. The functions below will tell you if your logged on user or computer are in (or below) an OU. Actually what they do is search the LDAP string (LDAP://CN=object,OU=container,OU=container,DC=mydomain,DC =com) for whatever you send in the sOU parameter. To be on the safe side, you should specify the OU like this 'OU=ouname,' including the trailing comma.

I'm sure there are more elegant or clever ways to do this but these work for me.

Code:
Function UserInOU(sOU)
' Returns true if the user is a member of the specified OU (or descendant)
UserInOU = (InStr(1, sUserDN, UCase(sOU)) > 0)
End function

Function ComputerInOU(sOU)
' Returns true if the computer is a member of the specified OU (or descendant)
ComputerInOU = (InStr(1, sComputerDN, UCase(sOU)) > 0)
End function

SHARE: