+ Post New Thread
Results 1 to 15 of 15
Coding Thread, Startup script woes in Coding and Web Development; Please could someone help? I have been getting a lot of help from srochford for which I am VERY GRATEFUL ...
  1. #1

    witch's Avatar
    Join Date
    Nov 2005
    Location
    Dorset
    Posts
    11,288
    Thank Post
    1,381
    Thanked 2,382 Times in 1,676 Posts
    Rep Power
    704

    Startup script woes

    Please could someone help? I have been getting a lot of help from srochford for which I am VERY GRATEFUL but I can't KEEP hassling him...
    I have borrowed a startup script to install fonts:

    InstallFonts
    Sub InstallFonts

    on error resume next
    Const FONTS = &H14
    dim oFSO,oShell, oFolder1, oFolder2, sRoot
    sRoot="\\dcserver01\SharedRes\fonts\"
    Set oShell = CreateObject("Shell.Application")
    set oFSO= CreateObject("scripting.filesystemobject")
    Set oFolder1 = oShell.Namespace(FONTS)
    set oFolder2=ofso.getfolder(sRoot)
    for each oFile in oFolder2.files
    sName=lcase(oFile.name)
    if right(sName,4)=".ttf" then
    if not ofso.fileexists(oFolder1.self.path & "\" & sName) then
    oFolder1.copyhere sRoot & sName
    end if
    end if
    next
    on error goto 0
    End Sub

    This is saved as 'Addfonts.vbs in the NETLOGON folder

    I am getting a 'line 1 char 1' error and I cannot fathom out why
    Not that I can do VBS anyway



    If I call up the script directly from \\dcserver01\NETLOGON\Addfonts.vbs I still get the same error
    I would be grateful for any assistance please

  2. #2

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    113
    What happens if you take out the Sub wrapper and just run the script raw?

  3. Thanks to jamesb from:

    witch (17th March 2010)

  4. #3

    witch's Avatar
    Join Date
    Nov 2005
    Location
    Dorset
    Posts
    11,288
    Thank Post
    1,381
    Thanked 2,382 Times in 1,676 Posts
    Rep Power
    704
    Which bits do I take out? Might be obvious to you but I'd rather ask!!

  5. #4


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,593
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296
    shouldnt installfonts on line 1 have a ' before it to show its a rem line rather than actual code?

  6. Thanks to sted from:

    witch (17th March 2010)

  7. #5
    Gerry's Avatar
    Join Date
    Jun 2007
    Location
    North Wales
    Posts
    431
    Thank Post
    60
    Thanked 38 Times in 35 Posts
    Rep Power
    24
    Try it like this:

    Code:
    'InstallFonts
    
    on error resume next
    Const FONTS = &H14
    dim oFSO,oShell, oFolder1, oFolder2, sRoot
    sRoot="\\dcserver01\SharedRes\fonts\"
    Set oShell = CreateObject("Shell.Application")
    set oFSO= CreateObject("scripting.filesystemobject")
    Set oFolder1 = oShell.Namespace(FONTS)
    set oFolder2=ofso.getfolder(sRoot)
    for each oFile in oFolder2.files
    sName=lcase(oFile.name)
    if right(sName,4)=".ttf" then
    if not ofso.fileexists(oFolder1.self.path & "\" & sName) then
    oFolder1.copyhere sRoot & sName
    end if
    end if
    next
    on error goto 0

  8. Thanks to Gerry from:

    witch (17th March 2010)

  9. #6

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Quote Originally Posted by sted View Post
    shouldn't installfonts on line 1 have a ' before it to show its a rem line rather than actual code?
    You could comment out that first line and then also comment out the lines beginning "sub" and "end sub" to make it a standalone script (as Gerry has shown)

    The benefit of doing it as Witch has shown is that when the script grows you can keep the logic clear (so you have have an "installfonts" "installNewFlashPlayer" "AddPrinter" "UpdateVirusScanner" etc etc)

  10. Thanks to srochford from:

    witch (17th March 2010)

  11. #7

    witch's Avatar
    Join Date
    Nov 2005
    Location
    Dorset
    Posts
    11,288
    Thank Post
    1,381
    Thanked 2,382 Times in 1,676 Posts
    Rep Power
    704
    Right
    I have taken out the subroutine etc and now have:

    on error resume next
    Const FONTS = &H14
    dim oFSO,oShell, oFolder1, oFolder2, sRoot
    sRoot="\\dcserver01\Shared Resources\fonts\"
    Set oShell = CreateObject("Shell.Application")
    set oFSO= CreateObject("scripting.filesystemobject")
    Set oFolder1 = oShell.Namespace(FONTS)
    set oFolder2=ofso.getfolder(sRoot)
    for each oFile in oFolder2.files
    sName=lcase(oFile.name)
    if right(sName,4)=".ttf" then
    if not ofso.fileexists(oFolder1.self.path & "\" & sName) then
    oFolder1.copyhere sRoot & sName
    end if
    end if
    next
    on error goto 0

    I don't get an error now but neither do the fonts install

    I have checked and the fonts are DEFINITELY in the folder called fonts in the Shared Resources folder (which is shared as SharedRes but I tried that and it made no difference)
    Now what have I done?

  12. #8


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,593
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296
    Quote Originally Posted by witch View Post
    Right
    I have taken out the subroutine etc and now have:

    on error resume next
    Const FONTS = &H14
    dim oFSO,oShell, oFolder1, oFolder2, sRoot
    sRoot="\\dcserver01\Shared Resources\fonts\"
    Set oShell = CreateObject("Shell.Application")
    set oFSO= CreateObject("scripting.filesystemobject")
    Set oFolder1 = oShell.Namespace(FONTS)
    set oFolder2=ofso.getfolder(sRoot)
    for each oFile in oFolder2.files
    sName=lcase(oFile.name)
    if right(sName,4)=".ttf" then
    if not ofso.fileexists(oFolder1.self.path & "\" & sName) then
    oFolder1.copyhere sRoot & sName
    end if
    end if
    next
    on error goto 0

    I don't get an error now but neither do the fonts install

    I have checked and the fonts are DEFINITELY in the folder called Fonts in the Shared Resources folder
    Now what have I done?
    if you ' out the on error resume next the script will tell you where its failing

  13. #9

    witch's Avatar
    Join Date
    Nov 2005
    Location
    Dorset
    Posts
    11,288
    Thank Post
    1,381
    Thanked 2,382 Times in 1,676 Posts
    Rep Power
    704
    If I ' out the on error resume next line I don't get any errors come up at all, but still no fonts!!

    It was definitely calling up the script as I got that error in the first place
    Would screaming help?

  14. #10

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    OK; Plan B - let's add some debugging! This is going to create a log file at c:\windows\temp\fonts.log and (hopefully!) write some info to the log file. Let the script run and collect that log file and post its contents; I hope that might show what's going on ...

    Code:
    Const FONTS = &H14
    dim oFSO,oShell, oFolder1, oFolder2, sRoot
    sRoot="\\dcserver01\Shared Resources\fonts\"
    Set oShell = CreateObject("Shell.Application")
    set oFSO= CreateObject("scripting.filesystemobject")
    set oLog=ofso.createtextfile("c:\windows\temp\fonts.log",true)
    Set oFolder1 = oShell.Namespace(FONTS)
    oLog.writeline oFolder1.name
    set oFolder2=ofso.getfolder(sRoot)
    oLog.writeline oFolder2.name
    for each oFile in oFolder2.files
    sName=lcase(oFile.name)
    oLog.writeline sName
    if right(sName,4)=".ttf" then
    oLog.wrietline "Font found"
    if not ofso.fileexists(oFolder1.self.path & "\" & sName) then
    oLog.writeline "Not installed yet"
    oFolder1.copyhere sRoot & sName
    oLog.writeline sRoot & sName
    end if
    end if
    next
    oLog.close

  15. #11

    witch's Avatar
    Join Date
    Nov 2005
    Location
    Dorset
    Posts
    11,288
    Thank Post
    1,381
    Thanked 2,382 Times in 1,676 Posts
    Rep Power
    704
    Back to where I started - try to run the above script and I get the original Line 1 character 1 compilation error.
    I have to change schools now but I am doing the same thing in the other school - just the path is different.
    So I'll be back in a bit

  16. #12

    witch's Avatar
    Join Date
    Nov 2005
    Location
    Dorset
    Posts
    11,288
    Thank Post
    1,381
    Thanked 2,382 Times in 1,676 Posts
    Rep Power
    704
    Right
    Other school: Vanilla system - Server 2003
    I have just put this in the default domain policy and it worked like a charm:

    on error resume next
    Const FONTS = &H14
    dim oFSO,oShell, oFolder1, oFolder2, sRoot
    sRoot="\\server\Resources\fonts\"
    Set oShell = CreateObject("Shell.Application")
    set oFSO= CreateObject("scripting.filesystemobject")
    Set oFolder1 = oShell.Namespace(FONTS)
    set oFolder2=ofso.getfolder(sRoot)
    for each oFile in oFolder2.files
    sName=lcase(oFile.name)
    if right(sName,4)=".ttf" then
    if not ofso.fileexists(oFolder1.self.path & "\" & sName) then
    oFolder1.copyhere sRoot & sName
    end if
    end if
    next
    on error goto 0

    I could even see all the fonts installing themselves.

    So where does that leave me?

    At the original school: 'lightly managed system', Server 2008 - if I run the above script with just the location changed I get the Line 1 Character 1 error

    The only differences I can see are that the scripts are saved in a slightly different place on the 2008server (somenumberorother/machine/scripts) but I put the Addfonts.vbs in there anyway.

    The only other thing I have seen, is that if I put the Addfonts.vbs on the desktop, click 'open with' and choose 'Microsoft Windows Based Script Host' (not that I know what that is, I was just clicking hopelessly by then) then I get no errors at the school where the script works, and the familiar line 1 char 1 error at the school in which it doesnt!
    I am thinking that it HAS to be the line pointing to the fonts folder but I can't see how that is wrong.
    Still, got it working in one school...
    Shame it is my boss in the OTHER SCHOOL WHO ASKED ME TO DO IT AS HE HAS SOME FONTS HE WANTS TO USE!! (cue Kermit arms)

  17. #13

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    OK; looks like somehow the .vbs file isn't associated with cscript or wscript which is why it's saying "what do you want to open it with"

    That needs to be fixed but maybe on another day :-)

    For now, can you change the machine startup script so instead of saying "addfonts.vbs" it says "cscript addfonts.vbs" and see what that does.

  18. #14

    witch's Avatar
    Join Date
    Nov 2005
    Location
    Dorset
    Posts
    11,288
    Thank Post
    1,381
    Thanked 2,382 Times in 1,676 Posts
    Rep Power
    704
    Got it going!
    Several problems: Server 2008 set up to NOT look at netlogon for scripts
    Name of folder wrong: needed to be shared name, not folder name
    And finally (and no, I didn't work it out for myself...)
    The shared resources permissions were for domain users only so the computers couldnt access the fonts folder as they were running startup scripts before logon. Changed permissions to 'everyone' and all is now well.
    I will need to look at the permissions on the resources folder in my other school - I don't really want people able to access it if not on the domain!
    THANKS very much for all your help - I've learned a lot so far this week

  19. #15


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,593
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296
    Quote Originally Posted by witch View Post
    Got it going!
    Several problems: Server 2008 set up to NOT look at netlogon for scripts
    Name of folder wrong: needed to be shared name, not folder name
    And finally (and no, I didn't work it out for myself...)
    The shared resources permissions were for domain users only so the computers couldnt access the fonts folder as they were running startup scripts before logon. Changed permissions to 'everyone' and all is now well.
    I will need to look at the permissions on the resources folder in my other school - I don't really want people able to access it if not on the domain!
    THANKS very much for all your help - I've learned a lot so far this week
    change everyone to authenticated users that includes pc accounts

  20. Thanks to sted from:

    witch (17th March 2010)

SHARE:
+ Post New Thread

Similar Threads

  1. BGInfo via VBS startup script?
    By gshaw in forum Windows
    Replies: 19
    Last Post: 18th July 2012, 02:51 AM
  2. Startup Script Running after login
    By glennda in forum Windows
    Replies: 6
    Last Post: 17th November 2009, 11:54 PM
  3. DelProf anomaly in startup script
    By Ignatius in forum Windows Server 2000/2003
    Replies: 3
    Last Post: 14th August 2009, 04:48 PM
  4. Startup Script
    By Chuckster in forum Windows
    Replies: 5
    Last Post: 26th February 2009, 12:53 PM
  5. RM CC3 Startup Script
    By randle in forum Windows
    Replies: 4
    Last Post: 30th July 2007, 02:56 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
  •