witch Posted March 16, 2010 Posted March 16, 2010 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
jamesb Posted March 16, 2010 Posted March 16, 2010 What happens if you take out the Sub wrapper and just run the script raw? 1
witch Posted March 16, 2010 Author Posted March 16, 2010 Which bits do I take out? Might be obvious to you but I'd rather ask!!
sted Posted March 16, 2010 Posted March 16, 2010 shouldnt installfonts on line 1 have a ' before it to show its a rem line rather than actual code? 1
Gerry Posted March 16, 2010 Posted March 16, 2010 Try it like this: '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 1
srochford Posted March 16, 2010 Posted March 16, 2010 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) 1
witch Posted March 16, 2010 Author Posted March 16, 2010 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?
sted Posted March 16, 2010 Posted March 16, 2010 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
witch Posted March 16, 2010 Author Posted March 16, 2010 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?
srochford Posted March 16, 2010 Posted March 16, 2010 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 ... 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
witch Posted March 16, 2010 Author Posted March 16, 2010 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
witch Posted March 16, 2010 Author Posted March 16, 2010 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)
srochford Posted March 16, 2010 Posted March 16, 2010 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.
witch Posted March 17, 2010 Author Posted March 17, 2010 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
sted Posted March 17, 2010 Posted March 17, 2010 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 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now