/build/static/layout/Breadcrumb_cap_w.png

Logoff Script to copy one file.

Hi all,

I'm trying to use a VB script to copy a file from under the user profile relating to a piece of software. I'm thinking of trying to copy it just before or as the user is logging off. The script I am using is below. I have it linked in Group Policy under User Configuration, Policies, Windows Settings, Scripts, Logoff. The script does not appear to run or is getting cancelled before it has a chance to run. Am I missing something? Please give me all the basic's to look at please.

strComputer = "."
Set oShell = WScript.CreateObject ("WSCript.shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'explorer.exe'")
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strUserName)
Next

oshell.Run "xcopy ""C:\Users\" & strUsername & "\AppData\Local\VirtualStore\Windows\Payroll.ini"" ""M:\Sage Payroll Favourites - Do Not Delete\"" /E /Y",1,True
WScript.Quit()

0 Comments   [ + ] Show comments

Answers (2)

Posted by: mahendraKumar 12 years ago
Senior Yellow Belt
0
check this link
http://technet.microsoft.com/en-us/library/cc781354(v=ws.10).aspx
Posted by: Trinity 12 years ago
Brown Belt
0
You could also use Folder.CopyHere method. A progress bar will be displayed prior to log off. This example contains an IF EXISTS ELSE THEN statement that can be easily removed. If you remove the IF EXISTS ELSE THEN statement you will need to remove the END IF as well.

strSourceFolder = ""C:\Users\" + strUsername + "\AppData\Local\VirtualStore\Windows\""
strTargetFile="Payroll.ini"
strDsetinationFolder = "M:\Sage Payroll Favourites - Do Not Delete\"

Set objShellApp = CreateObject("Shell.Application")
Set objFolder = objShellApp.NameSpace(strSourceFolder)
'---------------------------------------------------------------------------
If objFSO.fileExists(strSourceFolder + strTargetFile) Then
Else
objFolder.CopyHere strDestinationFolder + strTargetFile, FOF_CREATEPROGRESSDLG 'Change the install file(s) location as needed.
End If
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ