simons2009 (28th May 2009)
I would like to make a vbs script that backups up all the files located in x:\xxx\session\*.* to c:\temp\winteg by finding the path in the following registry key:
[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![]()
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
I think we are on the right track.
But when i run the new script i get the following dialogs:
- Font is in c:\wInteg6\IbsFont.fon
- Line 10 Car 3 Error: Path not found Code: 800A004C Source: VBScript error.
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.![]()
You wanted this as a VBS script or are you not picky about what scripting language?
Az
something along those lines ?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
@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
Thanks for getting back to me so fasti will have to test it out tommorow at work as my wife isnt well today.
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
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.
You can alter the paths there ( strPath being the source and the latter being the destination of where you want the files to go from and to )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; 26th May 2009 at 12:53 PM.
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![]()
Just delete the 2 lines I have made in bold so it is like
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
simons2009 (28th May 2009)
:-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
------------------------
There are currently 1 users browsing this thread. (0 members and 1 guests)