Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

Moving Files

$
0
0
I want to move files (no shortcuts) from the logged in users desktop to a network drive. I think I am close to getting my script set-up properly but just can't quite get it there. This is what I currently have, but I am stuck on actually capturing the the log-in name - the login name would need to be inserted for (username)
Code:

Option Explicit
'Declare Variables
Dim sOriginFolder, sDestinationFolder, sFile, oFSO
Dim WshShell, WshSysEnv, sUserProfile
 
'get user profile
Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
sUserProfile = WshSysEnv("USERPROFILE")
 
'Setting file paths for the copy
Set oFSO = CreateObject("Scripting.FileSystemObject")
sOriginFolder = sUserProfile & "\Desktop"
sDestinationFolder = "\\ServerName\\" & sUserProfile
 
'Copy the File
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
  If Not oFSO.FileExists(sDestinationFolder & "\" & oFSO.GetFileName(sFile)) Then
        oFSO.GetFile(sFile).Copy sDestinationFolder & "\" & oFSO.GetFileName(sFile), True
  End If
Next


Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>