none
How to load a file to Virtual Memory using another account RRS feed

  • Question

  • I met a problem while designing a private tool.

    I need to load two log files from an intranet server to compare data inside. But current loggin user does not have such access. I need to use another account to access these files and load them.

    There seems no such support for System.IO.File.Open(). Command Runas can not return data inside for me to compare. Is there any function can solve this?

    Current PC 

    Target VM

    Account A

    Account B

    App to compare data

    File X

    File Y

    Friday, January 4, 2013 4:04 AM

Answers

All replies

  • Can anybody help me on this? Thank you firstly.
    Friday, January 4, 2013 6:53 AM
  • Hi Jock,

    Welcome to the MSDN Forum.

    It seems that you need to run a new process with different user account. So please take a look at this code project: http://www.codeproject.com/Articles/61064/Impersonate-as-another-user-to-run-a-program  

    This is an extension to the "runas" command in windows, so the current user can impersonate as another user torun a program.

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 7, 2013 4:55 AM
    Moderator
  • Hi, Mike

    Thanks for your reply. I think what I need is not only start a process with different user, but also load the file content into Virtual Memory because I need to compare them. Is there any function like below stream handle actions to do this?

    FileStream fs = File.Open(filePath); //Do this via another user account

    Looking forward to your help. Thanks a lot.~

    Jock Guo

    Thursday, January 10, 2013 8:18 AM
  • Hi Jock,

    Welcome to the MSDN Forum.

    OS knows the memory is virtual or not, for a user application, it doesn't care it is run in virtual memory or not.

    So please try first you can use the above method to create a new process to get the file correctly, thank you.

    If you have any concerns, please feel free to follow up.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 10, 2013 9:32 AM
    Moderator
  • I will try this first. But I didn't get any idea How I can compare contents in two files by only starting a new process...
    Wednesday, January 16, 2013 8:20 AM