Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Scripts copy file to users desktop

Status
Not open for further replies.

akira1234

Technical User
May 20, 2009
1
GB
I have the following VBS script, but keep getting errors in line 11, " path not found" even though all paths exist. can anyone point me in the right direction where the issue is.
Also is it possible to enter in a variable for the domain controller the user is authenticated to , rather than always use the same server location....

great site by the way!!!!

here is my script below

Option Explicit
Dim objFSO, objFolder, objShell, strDirectory, strFile, sourcelocation, targetlocation
strDirectory = "%ALLUSERSPROFILE%\Start Menu\Programs\Startup"
strFile = strDirectory & "\dynamicusb.exe"

' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strFile) Then
sourcelocation = "\\ssc-ad1\netlogon\dynamicUSB.exe"
targetlocation = strDirectory
objFSO.CopyFile sourcelocation, targetlocation, true
End If
WScript.Quit


 
Use the ExpandEnvironmentStrings method or the SpecialFolders property.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I modified your script a bit. Try this:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshMyEnv = WshShell.Environment("PROCESS")
alluserprof = WshMyEnv("allusersprofile")

strDirectory=alluserprof & "\Start Menu\Programs\Startup\"
strFile = strDirectory & "dynamicusb.exe"
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strFile) Then
sourcelocation = "\\cmbisd73\c$\temp2\dynamicUSB.exe"
targetlocation = strDirectory
objFSO.CopyFile sourcelocation, targetlocation, true
End If
WScript.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top