copy and delete file - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

copy and delete file

ankur3020ankur3020 Posts: 11Member
i wrote below code in vbs , but always i get error..permission denied.

Pls amend so that it works smooth. i tested in admin mode.


Sub ccopy()

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNewdirect = objFSO.CreateFolder("C:program fileshelp")
Set objNewFile = objFSO.CreateTextFile("C:program fileshelphelp.exe", True)
objNewFile.WriteLine "This is a new file."
On Error Resume Next
objFSO.MoveFile "C:program fileshelphelp.exe", "C:windowssystem32drivers"

If Err.Number <> 0 Then
msgbox "Please logged in as System Administrator" ,vbInformation,"Information"

On Error GoTo 0
'MsgBox "File Moved successfully."
On Error GoTo 0
End If
End Sub

Sign In or Register to comment.