+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
Scripts Thread, VBS to Backup Folder and then Restore from Reg in Coding and Web Development; Another question apart from the one in the last box is: Can i get the backup script to look for ...
  1. #16

    Join Date
    May 2009
    Posts
    20
    Thank Post
    4
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Another question apart from the one in the last box is:

    Can i get the backup script to look for the default TEMP folder from the windows System Variable and copy the files in there under winteg e.g. so it doesnt matter which temp they use. And then i would like to copy the saved into the new c:\winteg\kcs\session605 folders:


    Sctipt 1 - checks for C:\temp then creates it
    -----------------
    Option Explicit
    Dim objFSO, objFolder, objShell, strDirectory
    strDirectory = "c:\tempkcs"

    ' Create the File System Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    ' Note If..Exists. Then, Else ... End If construction
    If objFSO.FolderExists(strDirectory) Then
    Set objFolder = objFSO.GetFolder(strDirectory)
    Else
    Set objFolder = objFSO.CreateFolder(strDirectory)
    End If

    If err.number = vbEmpty then
    Set objShell = CreateObject("WScript.Shell")
    Else WScript.echo "VBScript Error: " & err.number
    End If
    -----------------------

    Script 2 - backup files from old Wintegrate version to c:\tempkcs\session
    -----------------------
    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
    else
    set oFile=ofso.getfile(sFile)
    sfolder=oFile.parentfolder & "\session"
    ofso.copyfolder sFolder , "c:\tempkcs\winteg", true
    end if
    ------------------------

    Script 3 - copys files in C:\new winteg folder\session
    -------------------------
    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:\tempkcs\winteg" , sFolder, true
    end if
    ----------------------------


    Ok questions

    How do i add to Script 3 to copy everything from c:\tempkcs\winteg to the following folders:
    C:\[Path from Ibs font]\Session
    C:\[Path from Ibs font]\KCS\Session605

    Also after that is completed i want it to remove the c:\tempkcs folder from the c: so everything is nice and tidy.


    Thanks,
    Simon
    Last edited by simons2009; 28th May 2009 at 04:14 AM.

  2. #17

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361
    Quote Originally Posted by simons2009 View Post
    Another question apart from the one in the last box is:

    Can i get the backup script to look for the default TEMP folder from the windows System Variable and copy the files in there under winteg e.g. so it doesnt matter which temp they use. And then i would like to copy the saved into the new c:\winteg\kcs\session605 folders:


    Sctipt 1 - checks for C:\temp then creates it
    -----------------
    Option Explicit
    Dim objFSO, objFolder, objShell, strDirectory
    Dim newfolder
    strDirectory = "c:\tempkcs"

    ' Create the File System Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    ' Note If..Exists. Then, Else ... End If construction
    If objFSO.FolderExists(strDirectory) Then
    Set objFolder = objFSO.GetFolder(strDirectory)
    wscript.echo "Folder exists : " & strDirectory
    Else
    Set objFolder = objFSO.CreateFolder(strDirectory)
    wscript.echo "Folder does not exist : " & strDirectory
    Set newfolder = oFSO.CreateFolder(strDirectory)
    wscript.echo "A new folder has been created at: " & strDirectory

    End If

    If err.number = vbEmpty then
    Set objShell = CreateObject("WScript.Shell")
    Else WScript.echo "VBScript Error: " & err.number
    End If
    -----------------------

    Script 2 - backup files from old Wintegrate version to c:\tempkcs\session
    -----------------------
    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
    else
    set oFile=ofso.getfile(sFile)
    sfolder=oFile.parentfolder & "\session"
    ofso.copyfolder sFolder , "c:\tempkcs\winteg", true
    end if
    ------------------------

    Script 3 - copys files in C:\new winteg folder\session
    -------------------------
    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
    ofso.copyfolder "c:\tempkcs\winteg" , sFolder & "\session", true
    ofso.copyfolder "c:\tempkcs\winteg" , sFolder & "\KCS\Session605", true
    oFSO.DeleteFolder "c:\tempkcs", True
    end if
    ----------------------------


    Ok questions

    How do i add to Script 3 to copy everything from c:\tempkcs\winteg to the following folders:
    C:\[Path from Ibs font]\Session
    C:\[Path from Ibs font]

    Also after that is completed i want it to remove the c:\tempkcs folder from the c: so everything is nice and tidy.


    Thanks,
    Simon
    I have altered the script inside of the quote above some what so should help you out to a degree.

    You should be able to combine the 3 scripts together ( obviously getting rid of the repeated variables ie oFSO etc and keep all the variables at the top of the script and it will obviously make it a longer script.

    What you can also do is the common functions such as deleting the registry key etc you could make as functions and call the functions from within the main script.

    I have not got time to have a go at it right now but will have a go at it when I get home this evening unless srochford beats me to it lol

  3. #18

    Join Date
    May 2009
    Posts
    20
    Thank Post
    4
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Ill give the script you made try soon, the truth is I do not want to combine all 3, as I have the installer running in the correct order during the installation process so I am happy with them kept separate.

    My boss asked me another question which makes things more complicated.

    Can we adjust the script to look at and use the TEMP folder specified the windows environmental variables instead of specifying the folder and making it in the c:\ etc
    For instance my TEMP location is %SystemRoot%\TEMP

    Then we can make the tempkcs in that folder then delete it afterword.

    Thanks again,
    Simon :-D
    Last edited by simons2009; 28th May 2009 at 07:45 AM.

  4. #19

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361
    Quote Originally Posted by simons2009 View Post
    Ill give the script you made try soon, the truth is I do not want to combine all 3, as I have the installer running in the correct order during the installation process so I am happy with them kept separate.

    My boss asked me another question which makes things more complicated.

    Can we adjust the script to look at and use the TEMP folder specified the windows environmental variables instead of specifying the folder and making it in the c:\ etc
    For instance my TEMP location is %SystemRoot%\TEMP

    Then we can make the tempkcs in that folder then delete it afterword.

    Thanks again,
    Simon :-D
    no problem - I will look into both either on my lunch or when I get home unless someone else beats me to it.

  5. #20

    Join Date
    May 2009
    Posts
    20
    Thank Post
    4
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Looks like i bet you to it lol here is what im using now, thank you all so much.

    Backup session script

    Code:
    set oFSO=createobject("scripting.filesystemobject")
    set oShell=createobject("wscript.shell")
    Dim objFSO, objFiles, objShell, intCount
    Dim strFile, strName, strLongName, strDirectory, strEnv, strExt
    Set objShell = CreateObject("Wscript.Shell")
    strEnv = objShell.ExpandEnvironmentStrings("%temp%")
    intcount = 0
    
    
    on error resume next
    sFile=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont")
    on error goto 0
    if sFile="" then 
    else
    set oFile=ofso.getfile(sFile)
    sfolder=oFile.parentfolder & "\session"
    ofso.copyfolder sFolder , strEnv & "\tempkcs" , true
    end if
    Last edited by simons2009; 2nd June 2009 at 07:07 AM.

  6. #21

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361
    Quote Originally Posted by simons2009 View Post
    Looks like i bet you to it lol here is what im using now, thank you all so much.

    Backup session script

    Code:
    set oFSO=createobject("scripting.filesystemobject")
    set oShell=createobject("wscript.shell")
    Dim objFSO, objFiles, objShell, intCount
    Dim strFile, strName, strLongName, strDirectory, strEnv, strExt
    Set objShell = CreateObject("Wscript.Shell")
    strEnv = objShell.ExpandEnvironmentStrings("%temp%")
    intcount = 0
    
    
    on error resume next
    sFile=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont")
    on error goto 0
    if sFile="" then 
    else
    set oFile=ofso.getfile(sFile)
    sfolder=oFile.parentfolder & "\session"
    ofso.copyfolder sFolder , strEnv & "\tempkcs" , true
    end if
    Session Restore Script

    Code:
    set oFSO=createobject("scripting.filesystemobject")
    set oShell=createobject("wscript.shell")
    Dim objFSO, objFiles, objShell, intCount
    Dim strFile, strName, strLongName, strDirectory, strEnv, strExt
    Set objShell = CreateObject("Wscript.Shell")
    strEnv = objShell.ExpandEnvironmentStrings("%temp%")
    intcount = 0
    
    
    on error resume next
    sFile=oShell.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts\IbsFont")
    on error goto 0
    if sFile="" then 
    else
    set oFile=ofso.getfile(sFile)
    sfolder=oFile.parentfolder & "\session"
    ofso.copyfolder sFolder , strEnv & "\tempkcs" , true
    end if
    whats the difference between the 2 scripts ?

  7. #22

    Join Date
    May 2009
    Posts
    20
    Thank Post
    4
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Whoops the copy and paste from the VMWare machine played up

    Here is the restore script:

    Code:
    set oFSO=createobject("scripting.filesystemobject")
    set oShell=createobject("wscript.shell")
    
    Dim objFSO, objFiles, objShell, intCount
    Dim strFile, strName, strLongName, strDirectory, strEnv, strExt
    Set objShell = CreateObject("Wscript.Shell")
    strEnv = objShell.ExpandEnvironmentStrings("%temp%")
    intcount = 0
    
    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 
    ofso.copyfolder strEnv & "\tempkcs" , sFolder & "\session", true
    ofso.copyfolder strEnv & "\tempkcs" , sFolder & "\KCS\Session605", true
    oFSO.DeleteFolder strEnv & "\tempkcs", True
    end if

  8. #23

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,680
    Thank Post
    3,210
    Thanked 1,030 Times in 955 Posts
    Rep Power
    361
    no problem - just thought they looked the same lol. Let me guess you need your 2nd coffee lol J/K

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 19
    Last Post: 5th March 2009, 08:13 PM
  2. Moodle - Backup and Restore
    By danIT in forum Virtual Learning Platforms
    Replies: 3
    Last Post: 17th December 2008, 10:11 PM
  3. VBS Script to copy a folder
    By FN-GM in forum Scripts
    Replies: 2
    Last Post: 23rd February 2008, 01:08 PM
  4. Replies: 4
    Last Post: 24th January 2007, 11:39 PM
  5. Simple backup and restore
    By adamyoung in forum Wireless Networks
    Replies: 7
    Last Post: 25th August 2006, 08:13 AM

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
  •