none
Automatically run commands when Visual Studio starts

    Question

  • In our shop we have several domains with no trust relationships (e.g. to keep dev away from prod).  So devs like me have Windows accounts in each domain.  That means that, when running VS to develop something for a different domain, we need to run as a user in that domain (We use Sysinteral's shellrunas to help us with that).

    Now, to partially simulate the other environments (servers) I map certain directories to drive letters on my workstation.  So if the server has a "D:" drive, I have a directory ..\Documents\D_Drive and I have a network mapping to \\localhost\...\D_Drive as drive letter D: on my workstation.

    The problem I have is that when I start VS as a user in the "other" domain, initially VS cannot access the mapped D: drive, even though it is local.  Currently what I do is:

    1. Launch Visual Studio using ShellRunAs and specifying the domain id and user id I need to use

    2. Once launched, hit Ctrl-O to bring up the open file dialog

    3. I notice that the D: drive (the one mapped as explained above) has a red X.  However, if I simply click on the drive, the red X turns to a green connection.

    4. Load whatever solution I need to work on.

    What I'm trying to achieve is to automate the process in steps 2 and 3.  Doing it in a cmd file won't work since VS seems to run in it's own process.  That is, I tried this:

    startvs.cmd:

    NET USE D:

    devenv

    The NET USE command worked fine, but once VS launched, I still had to do the little process described above.

    Any thoughts on how I can automate the steps 2-3 I outlined above, so they happen whenever I start Visual Studio?


    • Edited by G Britton Wednesday, May 04, 2016 4:42 PM
    Wednesday, May 04, 2016 4:41 PM

Answers

All replies

  • Hi G Britton,

    For the step 2, if you want to open the Open File Dialog windows whenever you start your Visual Studio, please set your Visual Studio from Tools menu -> Options -> Environment -> Startup to set the At startup as "Show Open Project dialog box".

    For the step 3, we just can assign the driver location to D: through Tools -> Options -> Projects and Solutions -> General -> Projects location as below image shows.

    But it won't connect to D: automatically which is the default design for Visual Studio. For example, if I connect to database in Visual Studio, it won't connect the database when I open my Visual Studio next time. I still need to click the connection to re-connect it again. It can help us protect the content in database. In your situation, Windows need to protect the content in local driver, because the user that uses current Visual Studio is another domain user.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 05, 2016 8:20 AM
    Moderator
  • Actually, I don't want to open the filed dialog each time VS starts.  I do that as a workaround to my real problem.  I'm looking for a way to automate the manual steps I now go through whenever I launch Visual Studio.

    FWIW My projects are located in another location.  This request is not about opening projects, but about accessing folders mapped to drive letters when launching VS using an account in a different, untrusted domain.

    Thursday, May 05, 2016 11:15 AM
  • Hi G Britton,

    >> This request is not about opening projects, but about accessing folders mapped to drive letters when launching VS using an account in a different, untrusted domain.

    I'm afraid that you could not accessing folders mapped to drive letters using an account in a different, untrusted domain automatically. For safety concerns, both Visual Studio and Windows don't allow this type of operations, which can help us protect our information on Windows and Visual Studio. It's default design for Visual Studio and Windows.

    If any ideas for this design, I suggest you submit your ideas to Visual Studio Connect and then share the feedback link here. It is benefit to other communities who has the same problem to vote and add comments for your feedback.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 06, 2016 3:20 AM
    Moderator
  • Thanks Weiwei.  I suspected that might be the case.  However, I will file a connect item as you suggested.

    autoconnect suggestion

    Friday, May 06, 2016 12:48 PM
  • Hi G Britton,

    Thanks for your response and sharing the feedback link here.

    It can let other communities who has the same requirement to vote and add comments for your feedback. If there has enough votes for this feedback, I think the report team will treat this requirement seriously.

    Since you have submit this requirement to User Voice, please mark your feedback link as answer which can let other communities see this feedback link when open this thread. And then please wait for the response from Visual Studio Connect. Thanks for your feedback again.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 09, 2016 1:43 AM
    Moderator