Welcome, Register for free! or Login below:
EduGeek.net RSS Feeds 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.

Go Back   EduGeek.net Forums > Coding and Web Development > Scripts
Reply
 
LinkBack Thread Tools Search Thread
Sponsored Links
Old 25-05-2009, 03:48 AM   #1
 
simons2009's Avatar
 
Join Date: May 2009
Posts: 16
australia
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 simons2009 is an unknown quantity at this point
Wink VBS to Backup Folder and then Restore from Reg

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
  Reply With Quote
Old 25-05-2009, 08:21 AM   #2
 
srochford's Avatar
 
Join Date: Aug 2005
Location: London
Posts: 2,259
uk
Thanks: 46
Thanked 315 Times in 278 Posts
Blog Entries: 1
Rep Power: 72 srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future
Default

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
  Reply With Quote
Old 25-05-2009, 08:43 AM   #3
 
simons2009's Avatar
 
Join Date: May 2009
Posts: 16
australia
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 simons2009 is an unknown quantity at this point
Default

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.
  Reply With Quote
Old 25-05-2009, 11:48 AM   #4
 
azrael78's Avatar
 
Join Date: Sep 2007
Location: UK
Posts: 330
uk uk england
Thanks: 36
Thanked 28 Times in 25 Posts
Rep Power: 10 azrael78 has a spectacular aura about azrael78 has a spectacular aura about
Default

You wanted this as a VBS script or are you not picky about what scripting language?

Az
  Reply With Quote
Old 25-05-2009, 01:30 PM   #5
 
mac_shinobi's Avatar
 
Join Date: Aug 2005
Posts: 4,166
uk
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of
Default

Quote:
Originally Posted by simons2009 View Post
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.



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
something along those lines ?
  Reply With Quote
Old 25-05-2009, 04:42 PM   #6
 
srochford's Avatar
 
Join Date: Aug 2005
Location: London
Posts: 2,259
uk
Thanks: 46
Thanked 315 Times in 278 Posts
Blog Entries: 1
Rep Power: 72 srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future
Default

@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
  Reply With Quote
Old 25-05-2009, 05:38 PM   #7
 
mac_shinobi's Avatar
 
Join Date: Aug 2005
Posts: 4,166
uk
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of
Default

Quote:
Originally Posted by srochford View Post
@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
no problem - how does the parentfolder property work then ?

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 ?
  Reply With Quote
Old 25-05-2009, 06:38 PM   #8
 
srochford's Avatar
 
Join Date: Aug 2005
Location: London
Posts: 2,259
uk
Thanks: 46
Thanked 315 Times in 278 Posts
Blog Entries: 1
Rep Power: 72 srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future srochford has a brilliant future
Default

Quote:
Originally Posted by mac_shinobi View Post
no problem - how does the parentfolder property work then ?

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 ?
Yes.

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 :-)
  Reply With Quote
Old 26-05-2009, 02:00 AM   #9
 
simons2009's Avatar
 
Join Date: May 2009
Posts: 16
australia
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 simons2009 is an unknown quantity at this point
Default

Thanks for getting back to me so fast i 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
  Reply With Quote
Old 26-05-2009, 07:13 AM   #10
 
mac_shinobi's Avatar
 
Join Date: Aug 2005
Posts: 4,166
uk
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of
Default

Quote:
Originally Posted by simons2009 View Post
Thanks for getting back to me so fast i 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
ok so you have the following paths / folders :

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 ?
  Reply With Quote
Old 26-05-2009, 08:21 AM   #11
 
simons2009's Avatar
 
Join Date: May 2009
Posts: 16
australia
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 simons2009 is an unknown quantity at this point
Default

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.
  Reply With Quote
Old 26-05-2009, 12:47 PM   #12
 
mac_shinobi's Avatar
 
Join Date: Aug 2005
Posts: 4,166
uk
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of
Default

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

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..
  Reply With Quote
Old 27-05-2009, 08:34 AM   #13
 
simons2009's Avatar
 
Join Date: May 2009
Posts: 16
australia
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 simons2009 is an unknown quantity at this point
Default

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
  Reply With Quote
Old 27-05-2009, 08:36 AM   #14
 
mac_shinobi's Avatar
 
Join Date: Aug 2005
Posts: 4,166
uk
Thanks: 306
Thanked 307 Times in 287 Posts
Rep Power: 64 mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of mac_shinobi has much to be proud of
Default

Quote:
Originally Posted by simons2009 View Post
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
  Reply With Quote
Thanks to mac_shinobi from:
simons2009 (28-05-2009)
Old 28-05-2009, 02:51 AM   #15
 
simons2009's Avatar
 
Join Date: May 2009
Posts: 16
australia
Thanks: 3
Thanked 0 Times in 0 Posts
Rep Power: 0 simons2009 is an unknown quantity at this point
Default

:-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
------------------------
  Reply With Quote
Reply

EduGeek.net Forums > Coding and Web Development > Scripts

Similar Threads
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
Search Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:10 PM.
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright EduGeek.net




website uptime

© 2005 - 2009 EduGeek.net
SERVER: 4
no new posts