CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    VS2008 Start w/o Debugging command question

    I'm testing a project that needs to be run as administrator, is there any way to do this from VS 2008 IDE?

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: VS2008 Start w/o Debugging command question

    I have never seen any option for that but if it exists you would need to provide a valid admin login. So if you have access to an admin account why not just login as admin (or start another IDE using run as)?
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: VS2008 Start w/o Debugging command question

    The way it's set up, I'm using the IDE under a Standard User account so if I run the IDE as an administrator I will lose all the settings inside the Visual Studio. I agree that this is one way to do it, but the whole idea of setting up VS from scratch defeats the purpose.

    So, I guess I'll stick with what I'm doing now. Which is adding a manual breakpoint to the code using DebugBreak(). I then run the compiled code from Windows Explorer using Run as Administrator command, after which I attach the VS debugger thru the JIT debugger option. As you see this is far from being simple and handy.

    PS. Of course, if breaking the code isn't required right at the start, I attach to my process with the VS debugger later.

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: VS2008 Start w/o Debugging command question

    I played around a bit and actually came up with something that at least save you some manual steps. If you change Debugging settings to:
    Command: runas
    Command Arguments: /user:XXXX $(TargetPath)
    your app will be executed with other credentials.

    If you need to break at a specific location just insert
    Code:
    __asm {
      int 3;
    }
    and when it's reached you will be asked if you want to attach to the process.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  5. #5
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: VS2008 Start w/o Debugging command question

    Thanks. The DebugBreak() actually does just that. I mean int 3 part. I tried your approach with command line, but it doesn't really help because I will also need my own command line in this project. So I guess my only viable approach is to play with manifests and request elevation there (and then edit it out when I don't need it).

    I've switched to VS 2008 just recently, so I'm curious, is adding of a manifest automated in it? Or do I still have to add it manually?

  6. #6
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: VS2008 Start w/o Debugging command question

    Without having tried I guess you can add the requested command line arguments after $(TargetPath)
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  7. #7
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: VS2008 Start w/o Debugging command question

    Thanks, I'll try. So what about the manifest?

  8. #8
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: VS2008 Start w/o Debugging command question

    OK, I tried the manifest elevation and it still wants to restart the IDE under administrative account when I chose Debug command. It seems that there's no easy way around it.... Thanks for your help.

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