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

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
check this link
http://technet.microsoft.com/en-us/library/cc781354(v=ws.10).aspx
Answered 03/13/2012 by: mahendraKumar
Senior Yellow Belt

Please log in to comment
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
Answered 03/20/2012 by: Trinity
Brown Belt

Please log in to comment
Answer this question or Comment on this question for clarity