Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4171368
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:26:15+00:00 2026-05-21T00:26:15+00:00

I have a macro that opens a solution, connects to SourceSafe and downloads the

  • 0

I have a macro that opens a solution, connects to SourceSafe and downloads the latest version of each file inside the solution. To this point all works correctly.

Now I want to execute devenv.exe with /command option to run this macro and close the Visual Studio environment once the source code is downloaded, and at this point I’m having some problems:

If I use a macro like the one following these lines, Visual Studio starts, loads the solution, starts getting source code and then exits without waiting for the code to be completely downloaded.

DTE.Solution.Open("C:\ApeironDev\Soluciones\SolucioApeiron\SolucioApeiron.sln")
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("SolucioApeiron").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.ContextGetLatestVersion")
DTE.ExecuteCommand("File.Exit")

If I add a line to Sleep the macro for some time, say 20 minutes, this crashes with an error regarding error in COM call (I know, this is not an elegant way to do the job, but in order to test…).

DTE.Solution.Open("C:\ApeironDev\Soluciones\SolucioApeiron\SolucioApeiron.sln")
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("SolucioApeiron").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.ContextGetLatestVersion")
Threading.Thread.Sleep(New System.TimeSpan(0, 20, 0))
DTE.ExecuteCommand("File.Exit")

What I’m searching for is a way to start Visual Studio, load a solution, get the latest version of the source code (waiting for the process to finish) and then close the Visual Studio environment.
Any help?

Clarification, To run the macro I use the following command line:

devenv.exe /command "Macros.MyMacros.SourceControl.GetLastVersion"

Where Macros.MyMacros.SourceControl.GetLastVersion is the complete path to the macro containing the code above described.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T00:26:16+00:00Added an answer on May 21, 2026 at 12:26 am

    Given the fact that I have not found the solution I was looking for, I finally implemented a partial solution. Is not the solution I was looking for nor is the most elegant solution, but works, and since this is a temporal solution…well is best than nothing.

    I’m using the following macro:

    Sub GestLastVersionOfSourceCode()
        DTE.Solution.Open("C:\ApeironDev\Soluciones\SolucioApeiron\SolucioApeiron.sln")
        DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
        DTE.ActiveWindow.Object.GetItem("SolucioApeiron").Select(vsUISelectionType.vsUISelectionTypeSelect)
        DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.ContextGetLatestVersion")
    
        'Wait for 2 minutes
        For i As Integer = 0 To 2
            Threading.Thread.Sleep(New System.TimeSpan(0, 1, 0))
        Next
        DTE.ExecuteCommand("File.Exit")
    End Sub
    

    This macro runs without problems and give all the source code before closing the environment.

    For some reason I don’t know, the loop between the command that obtain the source code and the command that closes the solution induce the environment to wait for the get source command to end, thing that does not happen if I put the exit command directly after the get source code command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a VBA macro in an excel spreadsheet that opens all workbooks
I have a macro that looks like this: #define coutError if (VERBOSITY_SETTING >= VERBOSITY_ERROR)
I have an application that used Macro. In this macro I would like to
I have an Excel file that has a bunch of VBA and macro code
I have a simple Excel 2007 Macro that is reading a text file line
I have created a macro that opens a excel workbook and performs some operations
I have an excel file with VBA macro that starts when the Workbook is
I have a macro that I wrote to just help me with my unit
I have an umbraco macro that spits out the content of the page at
I have a VBA Word Macro that gets words from .txt list and color

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.