Site Maintenance this evening The site will be offline for hosting changes. Time TBC

+ Post New Thread
Results 1 to 5 of 5
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. #1
    contink's Avatar
    Join Date
    Jul 2006
    Location
    South Yorkshire
    Posts
    3,791
    Thank Post
    303
    Thanked 327 Times in 233 Posts
    Rep Power
    118

    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:

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

  2. #2
    contink's Avatar
    Join Date
    Jul 2006
    Location
    South Yorkshire
    Posts
    3,791
    Thank Post
    303
    Thanked 327 Times in 233 Posts
    Rep Power
    118

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

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,457
    Thank Post
    645
    Thanked 1,612 Times in 1,443 Posts
    Rep Power
    419

    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. #4
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34

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

  5. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,754
    Thank Post
    3,264
    Thanked 1,051 Times in 972 Posts
    Rep Power
    364

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


SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 17
    Last Post: 19th March 2010, 11:51 PM
  2. PHP IMAP check mail script
    By netadmin in forum Web Development
    Replies: 2
    Last Post: 22nd April 2007, 03:47 AM
  3. VB Script ti check for folder and then copy contents to PC
    By tosca925 in forum How do you do....it?
    Replies: 4
    Last Post: 2nd October 2006, 08:15 PM
  4. Replies: 4
    Last Post: 23rd March 2006, 06:27 AM
  5. Replies: 3
    Last Post: 1st March 2006, 12:08 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •