Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


How to copy file with Administrator's right


How to copy file with Administrator's right

Author
Message
allgames71
allgames71
Forum God
Forum God (1.4K reputation)Forum God (1.4K reputation)Forum God (1.4K reputation)Forum God (1.4K reputation)Forum God (1.4K reputation)Forum God (1.4K reputation)Forum God (1.4K reputation)Forum God (1.4K reputation)Forum God (1.4K reputation)

Group: Forum Members
Posts: 6, Visits: 7
Hello everybody ,

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

Mark
Mark
Forum God
Forum God (75K reputation)

Group: Moderators
Posts: 1.1K, Visits: 11K
In newer OS, security prevents you copying to the windows directory. You can't change this in your program. You need to make sure when you run the app you run it with an adminstrator account.
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search