Jump to content

vb script to check filesize and copy file not eq...


Recommended Posts

Posted

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:

 

//server/profile$/%username%/

 

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

Posted

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...

Posted

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

Posted

Genius / Masochist tag? gimme, gimme, gimme! :lol:

 

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.

 

Function UserInOU(sOU)
' Returns true if the user is a member of the specified OU (or descendant)
Dim oAdSys, sUserDN
Set oAdSys = CreateObject("ADSystemInfo")
sUserDN = UCase(oAdSys.UserName)
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)
Dim oAdSys, sComputerDN
Set oAdSys = CreateObject("ADSystemInfo")
sComputerDN = UCase(oAdSys.ComputerName)
ComputerInOU = (InStr(1, sComputerDN, UCase(sOU)) > 0)
End function

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...