I am trying to copy a file from a public share to path on the current users local profile C:\Users\%UserName%\Documents. I have the script below working when I manually put in the users username. However, I want to make the script global and use the current username of whichever user may be running the script at the time. The %username% variable does not work. Here is what I have so far. Please help if you can.
Dim ObjFso
Dim StrSourceLocation
Dim StrDestinationLocation
Dim StrSourceFileName
Dim StrDestinationFileName
StrSourceLocation = "\\servershare\path\path"
StrDestinationLocation = "C:\Users\%username%\Documents"
StrSourceFileName = "file.dsn"
StrDestinationFileName = "file.dsn"
'Creating the file system object
Set ObjFso = CreateObject("Scripting.FileSystemObject")
'Copying the file
ObjFso.CopyFile StrSourceLocation & "\" & StrSourceFileName, StrDestinationLocation & "\" & StrDestinationFileName
Dim ObjFso
Dim StrSourceLocation
Dim StrDestinationLocation
Dim StrSourceFileName
Dim StrDestinationFileName
StrSourceLocation = "\\servershare\path\path"
StrDestinationLocation = "C:\Users\%username%\Documents"
StrSourceFileName = "file.dsn"
StrDestinationFileName = "file.dsn"
'Creating the file system object
Set ObjFso = CreateObject("Scripting.FileSystemObject")
'Copying the file
ObjFso.CopyFile StrSourceLocation & "\" & StrSourceFileName, StrDestinationLocation & "\" & StrDestinationFileName