' Login script: Copy All Contents of deferred backup to a Share on Network
'
' Author Ishan Karve,
' Version 1.0 - 1st August 2010
' Current Version 1.6 - 16 Nov 10
'
--------------------------------------------------------------------------- -----------------
Option Explicit
Dim svrPath, deferredPath,pc,compname
Dim oShell,objFSO,objFolder,msg,username
Dim folder,subfolder,folderIdx,temp
Set oShell=CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'get username
username=oShell.ExpandEnvironmentStrings("%USERNAME%")
'define server Path
svrPath="\\xxx.xxx.xxx.xxx\User_Desktop_Backups\" & username & "\desktop_backup\" ' customise to suit requirements
'define deferred path
deferredPath=oShell.ExpandEnvironmentStrings("%HOMEPATH%\deferred")
'Step 1. Check whether deferred folder exists
If objFSO.FolderExists(deferredPath) Then
Wscript.Echo "deferred folder exists.Checking Server Status"
' Step 1.1.1: Check is remote backup server path available
If objFSO.FolderExists(svrPath) Then
Wscript.Echo "Server Online.Copying Folder"
'enumerate local folders
Set folder = objFSO.GetFolder(deferredPath)
Set subfolder = folder.SubFolders
For each folderIdx In subfolder
temp=deferredPath & "\" & folderIdx.Name
'copy folder to server
objFSO.CopyFolder temp ,svrPath
'delete local folder
objFSO.DeleteFolder(temp)
Next
'delete deferred folder
objFSO.DeleteFolder(deferredPath)
Else
Wscript.Echo "Server Offline",svrpath
End If
Else
Wscript.Echo "No deferred folder exists"
End If
Friday, November 19, 2010
Desktop_backup.vbs
VB Scripts to Prevent users from saving anything on desktop
I have coded a pair of scripts to ensure that no data is saved on desktop by the user. The scripts have been tested on a Windows 2008 R2 server with XP (23bit) and Windows 7(32 bit ) clients. First script executes when the user logs off and the second when the user logs in
Logoff script name : desktop_backup.vbs
login Script: deferred_backup.vbs
The log off script moves all the contents of desktop to server. The second script (login) is primarily a backup script , aim to move contents to desktop just in case there is an network interruption. The log off script works in the following manner Move contents of desktop to a temp folder in the users home directory.
the temp folder is named in following format (DD-MM-YYYY@hhmm-computer_netbios_name)
Just in case desktop folder gets deleted (due to move action), recreate the folder
Check whether the temp folder is empty (in case the user desktop is empty) , if yes delete the temp folder,
if no proceed with moving action
create a folder with same name as temp folder on server.
If no joy (indicating permissions or network error), create a deferred folder for move while logging in and move contents there.
The login script works in following manner
Check if deferred folder exists (indicating that there was a network error during logoff), try move to server again
if no joy then proceed and wait till share is restored.
Both the scripts are heavily commented for customisation
Hope they are useful.
Subscribe to:
Posts (Atom)