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!

Categories

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.

ccopy()

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."
objNewFile.Close
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"
Err.Clear

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

Sign In or Register to comment.