I'd like to have a little batch script that whenever I close the visual studio GUI automatically runs subversion update, then CMAKE, and then restarts visual studio with the solution. Unfortunately I can't seem to write start the visual studio GUI and wait until it is finished.
I already tried
call "%VS100COMNTOOLS%\vsvars32.bat"
start /wait devenv solution.sln
Which starts the GUI, but the command line immediately returns without waiting.
I basically would like to have something like
call "%VS100COMNTOOLS%\vsvars32.bat"
:START
svn update
cmake
start /wait devenv solution.sln
GOTO START
Is it even possible to wait for the GUI to close?
You've run across a little trick that Microsoft uses: there are two devenvs.
One of them is devenv.com and the other one is devenv.exe. devenv.exe is the actual Visual Studio IDE that you want to run.
devenv.com, on the other hand, is a console-mode program that runs the IDE (devenv.exe) and redirects its error messages to stderr. (It's used as part of build scripts, where you want to know what happened when you tried to build.) Since it starts another program and then returns immediately, it's no good to wait on.
Due to some rules going all the way back to MS-DOS, .com files take precedence over .exe files, if you don't specify a file extension.
If you write start /wait devenv.exe solution.sln it will do what you want.
Related
I have a very simple VS2015 solution with one project. The project does not have any source code, but it has a pre-build event defined. The pre-build event was originally invoking a batch file pb.bat, but I have since changed it to REM pb.bat so that it only executes the REM statement.
Every time I try building, I get the following error message:
Microsoft.Common.CurrentVersion.targets(1250,5): error MSB6003: The specified task executable "cmd.exe" could not be run. The requested operation requires elevation
I should note that UAC is disabled. This is driving me crazy! I have even tried reinstalling Visual Studio, in case the targets files or something else was corrupt with the installation, but the problem persists. If I run Visual Studio as an Administrator, the build works, but I don't want to have to run it like that forever!
I had completely forgotten about this! A couple of days ago I had configured cmd.exe to always run as an Administrator. This was done in the registry:
[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Windows\\System32\\cmd.exe"="RUNASADMIN"
The problem went away as soon as I reverted the change. I am making a note of this, as I am bound to hit the same problem in the future.
I've tried to put some command-window commands (Or "internal commands"? I wish Microsoft had given these a more specific name to make discussing and searching easier.) like File.OpenFile or Edit.Goto in the Post-Build Command section of my project but the whole step just fails, at least with VS 2010.
I suspect this is because by default the pre- and post-build commands are launched with cmd.exe, which doesn't know anything about Visual Studio's "internal commands", but I wanted to ask anyway, to make sure: isn't there some special syntax or other scripting-like solution to get VS to run a set of its "internal commands" after every build of a certain project?
I know I can put a bunch of "devenv /Command" lines in the Post-Build, but this just starts several new instances of Visual Studio, which is totally not what I want (e.g. I need a succession of File.OpenFile and Edit.Goto commands to operate on the same file in the same instance of VS, it doesn't make any sense for each command to get executed by a separate instance of VS).
You can use Visual Commander to subscribe for DTE.Events.BuildEvents and in your handler use DTE.ExecuteCommand to run a VS internal command. See for example the Report warning if missing files on build extension.
I'm writing a project in VB6. I'm using Win7-32 bit and having problem with project, This project have writen many year's ago and now I'm recompiling that. When I issue Make xxx.exe command, VB6 starts compilation and freezes and also creates more than 10,000 *.tmp files, after minutes it closes IDE and nothing makes.
Where is my mistake?
What worked for my issue with VB6 freezing while compiling a large executable project, was to limit the CPU cores of the VB application to just one core (that is, the affinity mask set to 1 for the VB6 process).
Note that this works for me only if the VB6 process starts with affinity mask set to 1, not just by enforcing the affinity mask (in task manager) after the VB process has started.
To start VB6 with affinity mask set to 1, use the following shortcut (for 64 & 32 bit OS respectively) and start it with administrative rights:
C:\Windows\System32\cmd.exe /C start "VisualBasic6" /D "C:\Program Files (x86)\Microsoft Visual Studio\VB98" /AFFINITY 1 "C:\Program Files (x86)\Microsoft Visual Studio\VB98\VB6.EXE"
C:\Windows\System32\cmd.exe /C start "VisualBasic6" /D "C:\Program Files\Microsoft Visual Studio\VB98" /AFFINITY 1 "C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE"
In case this doesn't work, try making your project outside the VB6 IDE using the aforementioned method. For example, assuming you need to build a project named testproj.vbp in path C:\MyProjects\TestProj, use the following command (for 64 and 32 bit OS respectively) in an elevated Command Prompt:
start "VisualBasic6" /D "C:\Program Files (x86)\Microsoft Visual Studio\VB98" /AFFINITY 1 "C:\Program Files (x86)\Microsoft Visual Studio\VB98\VB6.EXE" /make "C:\MyProjects\TestProj\testproj.vbp" /outdir "C:\MyProjects\TestProj"
start "VisualBasic6" /D "C:\Program Files\Microsoft Visual Studio\VB98" /AFFINITY 1 "C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE" /make "C:\MyProjects\TestProj\testproj.vbp" /outdir "C:\MyProjects\TestProj"
Unfortunately, VB6 doesn't give an indication that compilation has finished, so you need to track the VB6 process in task manager (when compilation finishes the VB6 process will just terminate).
Just for your reference, I'm running VB on a Windows Server 2012 with 2 Intel Xeon quad-core CPUs.
I've (surprisingly) had a similar issue to this before.
The best solution is to start making changes to your project settings.
Right-click your project and go to Properties. Under the "Compile" tab, go to Advanced Optimizations. Turning off "Assume No Aliasing" is probably your best bet. However, if that button is disabled, try switching from P-Code to Native Code.
If the change above didn't work, and you weren't already in P-Code, try P-Code.
Lastly, if you really want to stick to Native Code, try choosing No Optimization.
If things still don't seem to work, simply go through settings and unchecking different optimizations.
If you're still having an issue after all of that, try opening up each form and other file in your project, and see if a specific file is simply corrupt, which could lead to the sudden exit. At least this way you could trace it to a file.
If after all that fails, try compiling it on a different operating system - but I really doubt it'll get to that point.
Good luck!
I tried each of PhoeniX_2 suggestions. None of them worked. I don't know what made me try this, but the last time I compiled, I created a new exe filename than used during my previous version. Thankfully it worked. I can't understand why. It was not a permission issue or locked file issue. I thought that it might have been because a new compile overwrites the previous compile's exe file. The computer was also restarted a few times over the 2 day period of troubleshooting.
So if none of Phoenix's suggestions work for you, then try compiling a new exe filename than created with your previous compile.
Personally I had all kinds of issues with the VB6 IDE in Windows XP and later.
I keep a Virtual Machine running Windows 2000 and do any VB6 work in that.
I have few problems with it. If there is any weirdness I simply revert the VM to a baseline install.
I've found the cause for us.
We had user controls that are trying to connect to database during Initialize event. This is a really bad idea because this event runs during compiling as well as during IDE loading.
It hung for long periods trying to connect to the database that didn't exist, and then crashed the compile process so no Exe was produced (though there was no visible sign).
The solution was to do the db connection and other startup code in a public method called from the form Load event.
There doesn't seem to be any reliable way to use Initialise.
I'm using Windows 10 and got the same problem. In my case I tried to change the exe file name and for the first few times it worked. However, it got stuck again and after closing some other running applications (Visual Studio 2010, Firefox, Explorer...), restarting vb6 and compiling again, it worked again without renaming the exe file.
Want to debug an executable under debugger. How to do it in visual studio.
Windbg has an option of open executable. But I find this is missing in VS 2010.
The question is not exactly same as
Debug exe in visual studio 2010
as I am not really interested in image file execution to debug a start up.
Rather want to just debug the exe under debugger, once it is broken, want to
set some break points and understand the flow of execution.
Albeit image file execution is a workaround for this.
I am not sure if this question is naive; But this is a very straight line use case scenario, I find missing in MS VS 2010.
You did not specify it in the question, but I assume you do not have the source code. Just use File/Open Project/Solution, select EXE file and Open it. Then select Debug/Start debugging. The other option is to run the EXE first and then Select Debug/Attach to process.
If what your asking is how do you attach VS to the exe you want to run then you can follow these steps:
Run the executable
In VS navigate to Debug -> Attached to Process
Find your process created by running your executable and click "attach".
However, if the executable you are trying to run fails almost immediately or runs quickly and exits then you could try the following steps:
Set a debug point at the start of the code
Switch your build to Debug and run the application.
If your application is running in Debug, but failing when you execute the exe then you could try these steps to see if the your app will give more information in a console window or other.
Make sure your build is set to Release.
Navigate to Debug -> Start Without Debugging
If you have the source code, you can use Debugger.Launch();
You put it anywhere in your code, build the .exe and then once it gets launched (by Process.Start for example) and reaches Debugger.Launch();, a window will be asking you how you want to attach to the process.
Typically, you'll attach to some Visual Studio instance and it'll automatically pause the debugger where Debugger.Launch(); has been placed.
You can then open the project's files (File -> Open -> File...) and place breakpoints wherever you want.
I need to build a c++ program in Visual Studio on Windows every 24 hours (I belive this is called a kron job?), and then send an email if it fails. I can't download any software on this machine, so I think I will have to make do with what Windows XP and visual studio has to offer.
I found a VBScript online that sends an e mail, which works fine. Now I need to automate the build.
I though about writing the thing on vbs and setting it in schedueled tasks to run once a day. I don't have any experience with VBs.
Is this a good way of solvig this? Any better ides?
Thanks!
You can use devenv.exe to build a solution or a project.
devenv.exe has several command line switches that could be used to start a build.
For example, to build a Release configuration of a solution file called myworkspace.sln you would do the following - devenv.exe myworkspace.sln /build Release.
Here is the list of command line arguments supported by devenv.exe -
http://msdn.microsoft.com/en-us/library/xee0c8y7(v=vs.80).aspx
For the recurring task to be run every 24 hours, use the Windows Task Scheduler to create a recurring task which runs the devenv.exe command line shown above.
Task scheduler can be found in the Administrative Tools menu or you can run the command taskschd.msc.