3 Replies - 2576 Views - Last Post: 18 October 2012 - 10:14 PM Rate Topic: -----

#1 allgames71  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 02-October 12

How to copy files with Administrator's right

Posted 16 October 2012 - 01:39 PM

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

This post has been edited by no2pencil: 17 October 2012 - 01:50 PM
Reason for edit:: Added Code Tags


Is This A Good Question/Topic? 0
  • +

Replies To: How to copy files with Administrator's right

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: How to copy files with Administrator's right

Posted 17 October 2012 - 01:44 PM

Try running your VB6 program as an administrator.
Was This Post Helpful? 0
  • +
  • -

#3 allgames71  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 02-October 12

Re: How to copy files with Administrator's right

Posted 17 October 2012 - 11:56 PM

Thanks for your reply , Sir

But I don't understand the steps and that's why I ask this here.

Would you mind to write down the program here ? Thanks
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: How to copy files with Administrator's right

Posted 18 October 2012 - 10:14 PM

Yes, I would mind. If you won't do any work, I won't either. If you don't know how to run an exe as an administrator, then look it up. (Use google.) If you can't figure out how to use google, then find another line of work.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1