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!

How to copy files with Administrator's right

Status
Not open for further replies.

allgames71

Technical User
Oct 17, 2012
1
HK
Hello everybody , I'm using Windows 7

When I write VB6 program , I need to copy files to C:\Windows. But always fail as I don't have Administrator's Right. I found a program on web but also fail :

Option Explicit

Private Sub Command1_Click()
Const ssfDESKTOP = 0
Const ssfWINDOWS = 36
Dim OriginalFile As String
Dim CopiedFile As String
Dim F As Integer

With CreateObject("Shell.Application")
With .NameSpace(ssfDESKTOP).Self
OriginalFile = .Path & "\test-orig.txt"
End With
With .NameSpace(ssfWINDOWS).Self
CopiedFile = .Path & "\test-copy.txt"
End With
End With
F = FreeFile(0)
Open OriginalFile For Output As #F
Print #F, "Testing!"
Close #F
DoEvents
FileCopy OriginalFile, CopiedFile
Kill OriginalFile
MsgBox FileLen(CopiedFile)
End Sub

Please help me. Thanks a lot

 
There is no magic "break system security" incantation you can copy & paste, and even when you have admin rights that folder isn't a playplace.

Just don't try to do this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top