I need to copy files to the user profile on the computer using my VBS login
script, and I need to make it conditional. Currently I have the following:

Set oFSO = CreateObject("Scripting.FileSystemObject")

If oFSO.FileExists("c:\Folder\File.exe") Then
oFSO.GetFile("C:\Folder\File.exe").Attributes = 0 'In case it is read-only
oFSO.CopyFile \\server\share\file.exe, "c:\Folder\", True

End If

I need to do the following logic:

If exist C:\Documents and Settings\%username%\Application
Data\Microsoft\Signatures\%username%.htm
then copy \\server\share\%username%\*.* C:\Documents and
Settings\%username%\Application Data\Microsoft\Signatures\

If anyone can provide me with the code to do this, it would be greatly
appreciated. The conditional is not important, but the variable is.

THanks,

Michael

Re: File copy with variable by Pegasus

Pegasus
Mon Mar 10 11:52:05 CDT 2008

Here is how you can get %UserName%:
Set objWshShell = WScript.CreateObject("WScript.Shell")
UserName = objWshShell.Environment("PROCESS")("UserName")

Your batch file code is fine, apart from the missing double quotes
around the file/folder names that have embedded spaces:
If exist "%UserProfile%\Application
Data\Microsoft\Signatures\%username%.htm" xcopy
"\\server\share\%username%\*.*" "%UserProfile%\Application
Data\Microsoft\Signatures\" /d /y /c


"Michael" <support@microsoft.com> wrote in message
news:uiL%2350sgIHA.5208@TK2MSFTNGP04.phx.gbl...
>I need to copy files to the user profile on the computer using my VBS login
>script, and I need to make it conditional. Currently I have the following:
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
>
> If oFSO.FileExists("c:\Folder\File.exe") Then
> oFSO.GetFile("C:\Folder\File.exe").Attributes = 0 'In case it is
> read-only
> oFSO.CopyFile \\server\share\file.exe, "c:\Folder\", True
>
> End If
>
> I need to do the following logic:
>
> If exist C:\Documents and Settings\%username%\Application
> Data\Microsoft\Signatures\%username%.htm
> then copy \\server\share\%username%\*.* C:\Documents and
> Settings\%username%\Application Data\Microsoft\Signatures\
>
> If anyone can provide me with the code to do this, it would be greatly
> appreciated. The conditional is not important, but the variable is.
>
> THanks,
>
> Michael
>



Re: File copy with variable by Luuk

Luuk
Mon Mar 10 12:01:08 CDT 2008

Michael schreef:
> I need to copy files to the user profile on the computer using my VBS login
> script, and I need to make it conditional. Currently I have the following:
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
>
> If oFSO.FileExists("c:\Folder\File.exe") Then
> oFSO.GetFile("C:\Folder\File.exe").Attributes = 0 'In case it is read-only

it can also be 'not writable', because of lack of rights....?

--
Luuk