![]() | Register | FAQ | Members | Social Groups | User Map | Calendar | Search | Today's Posts | Mark Forums Read |
| Scripts If you need or have any scripts then get 'em here. |
| ||
| | | LinkBack | Thread Tools | Search Thread |
| Sponsored Links |
| | #1 |
![]() Join Date: May 2009
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts] "IbsFont"="C:\\wInteg6\\IbsFont.fon" In other words it will get the current install location C:\wInteg6\ from the reg key mentioned above as different customers install this to different locations and then it can backup all files from C:\wInteg6\session to c:\temp. Im am currently getting the customers to do this manually using the following vbs script but would prefer this to be done seamlessly: ======================== Const WINDOW_HANDLE = 0 Const NO_OPTIONS = 0 Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.BrowseForFolder _ (WINDOW_HANDLE, "Select a folder:", NO_OPTIONS, "C:\Scripts") Set objFolderItem = objFolder.Self objPath = objFolderItem.Path Const OverWriteFiles = True Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.CopyFolder objPath , "C:\temp\winteg" , OverWriteFiles ========================== Please help me find a way to do this automatically. Thanks, Simon |
| |
| | #2 |
![]() Join Date: Aug 2005 Location: London
Posts: 2,259
Thanks: 46
Thanked 315 Times in 278 Posts
Blog Entries: 1 Rep Power: 72 | I think this does what you want. It reads the fonts registry location and then copies everything from that folder to c:\temp\winteg It doesn't do much error checking, just a check to see if the font is installed Code: set oFSO=createobject("scripting.filesystemobject")
set oShell=createobject("wscript.shell")
on error resume next
sFolder=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont")
on error goto 0
if sFolder="" then
wscript.echo "Font not installed"
else
wscript.echo "Font is in " & sFolder
ofso.copyfolder sFolder , "c:\temp\winteg", true
end if
|
| |
| | #3 |
![]() Join Date: May 2009
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 | I think we are on the right track. But when i run the new script i get the following dialogs:
I think the issue is the value data in the registry contanis c:\wInteg6\IbsFont.fon and not just the path e.g. c:\wInteg6\ can we somehow get the vbs script to remove the IbsFont.fon so it will backup the folder correctly. Thankyou so far Steve. |
| |
| | #4 |
![]() Join Date: Sep 2007 Location: UK
Posts: 330
Thanks: 36
Thanked 28 Times in 25 Posts
Rep Power: 10 | You wanted this as a VBS script or are you not picky about what scripting language? Az |
| |
| | #5 | |
![]() Join Date: Aug 2005
Posts: 4,166
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 | Quote:
Code:
Dim x
Dim strPath
set oFSO=createobject("scripting.filesystemobject")
set oShell=createobject("wscript.shell")
on error resume next
sFolder=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont")
on error goto 0
if sFolder="" then
wscript.echo "Font not installed"
else
wscript.echo "Font is in " & sFolder
x = instrrev(sFolder,"\")
strPath=Left(sFolder,x)
ofso.copyfolder strPath , "c:\temp\winteg", true
end if
| |
| |
| | #6 |
![]() Join Date: Aug 2005 Location: London
Posts: 2,259
Thanks: 46
Thanked 315 Times in 278 Posts
Blog Entries: 1 Rep Power: 72 | @macshinobi - that looks right; thanks. That'll teach me to try posting before my second cup of coffee :-) Slightly different version below - just uses "parentfolder" to find out the foldername Code: set oFSO=createobject("scripting.filesystemobject")
set oShell=createobject("wscript.shell")
on error resume next
sFile=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont")
on error goto 0
if sFile="" then
wscript.echo "Font not installed"
else
set oFile=ofso.getfile(sFile)
sfolder=oFile.parentfolder
wscript.echo "Font is in " & sFolder
ofso.copyfolder sFolder , "c:\temp\winteg", true
end if
|
| |
| | #7 | |
![]() Join Date: Aug 2005
Posts: 4,166
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 | Quote:
so If I had c:\myFolder\sub_folder\file.txt Would that just take c:\myFolder\sub_folder and ignore the file.txt or what exactly ? | |
| |
| | #8 | |
![]() Join Date: Aug 2005 Location: London
Posts: 2,259
Thanks: 46
Thanked 315 Times in 278 Posts
Blog Entries: 1 Rep Power: 72 | Quote:
I can't think of any situation in which your technique wouldn't work (and yours is probably marginally faster; my code will have to read the disc to find out about the file) but I think parentfolder is just a bit tidier :-) | |
| |
| | #9 |
![]() Join Date: May 2009
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 | Thanks for getting back to me so fast If this works like your saying and it picks up the correct folder c:\winteg and ignores the extension how to i get it to look in the folder below e.g. c:\winteg\session so i can backup everything in that folder to the c:\temp folder? Hope i make sense. Thanks, Simon |
| |
| | #10 | |
![]() Join Date: Aug 2005
Posts: 4,166
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 | Quote:
c:\winteg\ c:\winteg\session c:\temp Are you wanting to change the path where it is copying or do you want another line of code that copies folder one to folder two or what exactly ? | |
| |
| | #11 |
![]() Join Date: May 2009
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 | Sorry for the confussion. What happens is the reg entry gives us the path c:\wInteg6\IbsFont.fon all i want is to drop the IbsFont.fon to so the path is c:\wInteg6 and then make the path = c:\winteg\session so i can backup that folder the folder to c:\temp. |
| |
| | #12 |
![]() Join Date: Aug 2005
Posts: 4,166
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 | Code: Dim x
Dim strPath
set oFSO=createobject("scripting.filesystemobject")
set oShell=createobject("wscript.shell")
on error resume next
sFolder=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont")
on error goto 0
if sFolder="" then
wscript.echo "Font not installed"
else
wscript.echo "Font is in " & sFolder
x = instrrev(sFolder,"g") '<----- HERE
strPath=lcase(Left(sFolder,x)) & "\session"
ofso.copyfolder strPath , "c:\temp\winteg", true '<-- Alter paths here
end if
strPath should now be c:\winteg\session and you said C:\temp so not sure if you mean just C:\temp or C:\temp\winteg but you can alter that yourself easily enough Also where it states HERE in the code above is where I have used the instrrev function to find the letter g in winteg and get rid of the rest of the text after the g hence chopping off the number 6 etc Hopefully the path in the registry key will always have something along the lines of x:\winteg where x is the drive letter ( C or whatever ) Last edited by mac_shinobi; 26-05-2009 at 12:53 PM.. |
| |
| | #13 |
![]() Join Date: May 2009
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 | After playing around with your code sujestions this works for me as required: --------------------- set oFSO=createobject("scripting.filesystemobject") set oShell=createobject("wscript.shell") on error resume next sFile=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont") on error goto 0 if sFile="" then wscript.echo "Font not installed" else set oFile=ofso.getfile(sFile) sfolder=oFile.parentfolder & "\session" wscript.echo "Font is in " & sFolder ofso.copyfolder sFolder , "c:\temp\winteg", true end if --------------------- Can you please tell me how to remove the dialog infroming me that the font is installed or not installed as i want it to be seamless?? Let me know. Thanks so much |
| |
| | #14 | |
![]() Join Date: Aug 2005
Posts: 4,166
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 | Quote:
Code: set oFSO=createobject("scripting.filesystemobject")
set oShell=createobject("wscript.shell")
on error resume next
sFile=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont")
on error goto 0
if sFile="" then
' DO NOTHING
else
' Copy files from source to destination
set oFile=ofso.getfile(sFile)
sfolder=oFile.parentfolder & "\session"
ofso.copyfolder sFolder , "c:\temp\winteg", true
end if
| |
| |
| Thanks to mac_shinobi from: | simons2009 (28-05-2009)
|
| | #15 |
![]() Join Date: May 2009
Posts: 16
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 | :-D It works!! :-) Thanks so much for your help you guys are awesome. One last request can you alter this code for me to pop up a message saying "Session Backup Does Not Exist" and if it does to popup a box saying "Session Files Restored Successfully" ------------------------ set oFSO=createobject("scripting.filesystemobject") set oShell=createobject("wscript.shell") on error resume next sFile=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont") on error goto 0 if sFile="" then ' DO NOTHING else ' Copy files from source to destination set oFile=ofso.getfile(sFile) sfolder=oFile.parentfolder & "\session" ofso.copyfolder "c:\temp\winteg" , sFolder, true end if ------------------------ |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Er, ok. How do i restore a backup of zimbra!!! | reggiep | *nix | 19 | 05-03-2009 09:13 PM |
| Moodle - Backup and Restore | danIT | Virtual Learning Platforms | 3 | 17-12-2008 11:11 PM |
| VBS Script to copy a folder | FN-GM | Scripts | 2 | 23-02-2008 02:08 PM |
| need advice on how to restore sysvol folder on only dc | projector1 | Windows | 4 | 25-01-2007 12:39 AM |
| Simple backup and restore | adamyoung | Networks | 7 | 25-08-2006 08:13 AM |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search Thread |
| |








