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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with copyfile Error

Status
Not open for further replies.

redlair

Technical User
Jun 29, 2004
54
0
0
US

In this script I am writing, I need to copy a lnk from a share to the all users desktop. When the script runs I get an error "Permission Denied". I have not been able to figure this one out. any ideas?

The line is as below

FSO.CopyFile "\\south01\mtmm\Microtype_Network.lnk",_ strDesktop

__________________________________________________________

Option Explicit
Dim objNetwork, FSO, WshShell, objFSO, strDesktop

'On error Resume Next
Set FSO =CreateObject("scripting.FileSystemObject")

'Copy MTM.bat to c:\
If FSO.FileExists("C:\MTM.bat") Then
FSO.DeleteFile("C:\MTM.bat")
End If

FSO.CopyFile "\\south01\mtmm\mtm.bat", "c:\", True

'Copy microtype_network.lnk to allusers desktop
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("AllUsersDesktop")
FSO.CopyFile "\\south01\mtmm\Microtype_Network.lnk",_ strDesktop

'Map K: drive to south01\keyboarding$
Set objNetwork = WScript.CreateObject("WScript.Network")

If fso.DriveExists("k:") Then

Else
objNetwork.MapNetworkDrive "K:" , "\\south01\keyboarding$"
End If

'If FSO.FolderExists("K:\south01\keyboarding$") Then
'Else
'objNetwork.MapNetworkDrive "K:" , "\\south01\keyboarding$"
'End If

'Execute MTMM.exe
WshShell.Run "k:\mtmm\mtmm.exe", 1, True


' End of Example VBScript.

 
I have figured out the problem is not on the share side it is on the all users side. But I still not shure why.
 
I assume that the error is on the line where you are copying microtype_network.lnk to the AllUsers desktop? If so, I have a couple of thoughts:

1. The file already exists.
2. The user running it does not have permission to modify the contents of the AllUsers Desktop folder.
3. You might try adding a Wscript.Echo strDesktop line before the copy line just for testing. That way you can be sure that strDesktop is set to the correct value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top