CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2012
    Posts
    13

    How to copy file with Administrator's right

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to copy file with Administrator's right

    Can't get around ADMINISTRATOR permissions, since Windows 95. Each version gets harder, and you didn't mention your OS.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Oct 2012
    Posts
    13

    Re: How to copy file with Administrator's right

    Thanks Sir ,

    I'm using Windows 7

    Even when I install Adobe Photoshop 5.0 , still file and Adobe folder can be installed and copied in program files. Such an old software still can write stuffs in Program Files and some dll in C:\Windows\System32 , but why can we write files in C:\Windows via VB6 ?

    Thanks for your tutorial.

  4. #4
    Join Date
    Oct 2012
    Posts
    59

    Re: How to copy file with Administrator's right

    Vb6 instalation RUN AS ADMINISTRATOR. Just right click on vb6.exe file, then choose (run as administrator)
    All your programs run as administrator. Of course you just can change folders rights from admin to other.

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to copy file with Administrator's right

    Because it calls the TRUSTED INSTALLER Service. This is the ONLY way to install in a private Windows folder. You cannot write to some areas. Period.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Oct 2012
    Posts
    59

    Re: How to copy file with Administrator's right

    Quote Originally Posted by dglienna View Post
    You cannot write to some areas
    He do not need to do this: write some area, just change settings of trusted instaler or do nothing and jus run programs as administrator.

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to copy file with Administrator's right

    Care to tell anyone HOW to "just change settings of trusted installer". Do nothing sounds better.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Oct 2012
    Posts
    59

    Re: How to copy file with Administrator's right

    Quote Originally Posted by dglienna View Post
    Care to tell anyone HOW to "just change settings of trusted installer". Do nothing sounds better.
    I agree. Better not change settings if you dont know what to do. Just run soft as admin. Who wants to change settings of trusted installer can find info in internet. See in this video how to change settings and gain full control:

    http://www.youtube.com/watch?v=y9TOWxZGbJc
    Last edited by Halosar7; October 20th, 2012 at 11:02 AM.

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to copy file with Administrator's right

    Try that on any WINDOWS or PROGRAM folder and see what happens when you try to INSTALL ANOTHER APP. No way to reverse the process other than clean install.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  10. #10
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: How to copy file with Administrator's right

    I think you should look up 'Elevated Rights'.... (this essentially, Asks the Windows UAC for permition, and the UAC will grant according to settings and user response...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  11. #11
    Join Date
    Jul 2012
    Posts
    4

    Re: How to copy file with Administrator's right

    Hi! As one of the options I can advise to use virtualization. For example, it can be boxedapp or thinapp.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured