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.
Related
Our previous development systems used Windows XP and Windows 7. Debugging C++ DLLs from Visual Studio worked great.
A recent move to Windows 10 has resulted in an annoying problem. We can debug once (using F5), but the 2nd time results in a linker error:
MyProg fatal error LNK1201: error writing to program database 'MyProg.pdb'
Trying to delete the .pdb manually in Explorer while Visual Studio is still open results in the error:
The action can't be completed because the file is open in devenv.exe
It doesn't matter whether you hit a breakpoint or not. Just start debugging once results in the problem. Re-starting Visual Studio resolves the issue (in the sense that you can debug once, but then you get the problem again).
If relevant:
x86 Visual Studio 2003.NET
targeting another x86 application
x64 Windows 10 Pro v1803
After hunting around for several hours some related, but unanswered, questions were found. Following suggestions in this MSDN article, along with some debugging of my own, this solution works:
Download FreePDB, a script written by MSDN user Toni76 (thanks Toni!)
Copy this script to a local folder (say C:\Apps\FreeDPB)
Download the latest version of SysInternals tool Handle (currently v4.21)
Copy handle.exe to C:\Apps\FreeDPB
NB! From the command line, run handle /? once. This is to agree the EULA. The script will not work if you skip this step!
Open Visual Studio, then Project > Properties > Build Events > Pre-Build Event
Set Command Line to C:\Apps\FreeDPB\freepdb $(ProjectName)
Set Description to Delete lock on PDB
...and now you don't need to restart Visual Studio to debug a 2nd time!
From comments, this works with multiple versions of Visual Studio on multiple versions of Windows.
Update
A more radical solution is described here which involves replacing a core Visual Studio DLL (NatDbgDE.dll). This solution only works for Visual Studio 2003 SP1, though.
In my case it was due to "Process Explorer" program, which was open alongside with my Visual Studio(I used it to check some properties of the exe I've created). After closing it problem solved.
I am currently using Visual Studio 2015 (Community Version) and I am trying to automate a data flow task that moves an SQL input into a Flat File output.
I have tested that the task works manually however I cannot find anywhere how to automate the process, any help would be greatly appreciated as I am very new to this, Thanks
You need to schedule a process that triggers your code/DTS. You can use SQL Server Agent, Windows Scheduler or other scheduler software.
If you are working with SSIS and your process is a DTS (I'm guessin it is because you mentioned "Data Flow Task"), then you can execute it using the command line with the dtexec program.
If you are using C#, Visual Basic or another programming language in Visual Studio, make sure to compile it as a Console Application so it generates an .exe file.
Finally schedule your program execution (either dtexec or the call to the .exe) in your scheduler software, with a custom timing (for example everyday at 7am, just weekends, etc.). Make sure to monitor the results afterwards!
I used Visual Studio 2010 on Windows 7 for a while and never had this problem, but with the current VS solution whenever I run the executable created from any Fortran project (both debug and release) I get the message
This task requires this application to have elevated permissions.
and I'm asked to restart Visual Studio as Administrator.
I don't want this, I want to create executables that run not as administrator unless right-clicked => run as administrator. That has always been the case for all my solutions except this one and I cannot figure out what I did different.
How can I change this behavior?
In your project's linker properties there is the manifest file group of options.
Inspect the value of
UAK Execution Level
Probably it is set as
requireAdministrator
You should change it to
asInvoker
I'm having a recurring issue on Windows 7 whereby on clicking the compile button in Inno Script Studio version 2.2.2.32 the application hangs indefinitely and refuses to respond. After end tasking and restarting the software the problem persists and it is only rectified on a restart of the operating system.
The problem seems to be an issue whereby the previously compiled Inno Setup executable cannot be overwritten by the newer version of the file.
Attempting to manually delete the file in file explorer results in the following dialog appearing but never completing:
Attempting the same through the command line results in a command that never terminates.
This appears to happen only when an installation is terminated prematurely usually because the script has encountered an error. On inspection of the file it has no ownership or permissions set. It does not seem to be related to Anti-Virus software as far as I can tell because I've disabled all the Sophos services I can see in the SCM.
Anybody have this issue before?
Try to workaround the issue by using an unique output filename for each compilation.
You can use:
[Setup]
OutputBaseFilename=setup-{#GetDateTimeString('yyyy-mm-dd-hh-nn-ss', '', '')}
Does this happen with another IDE?
I mean classic Compile32.exe (default Inno Setup IDE) or Visual & Installer for Microsoft Visual Studio or RAD & Installer for Embarcadero RAD Studio?
This could be IDE related thing or Windows so we need to eliminate them one by one.
Running a powershell script as a post-build event in Visual Studio fails despite the fact that that same script runs fine from the commandline. Why is this?
Sorry for re-animating an ancient question but since my search lead me to this post and my resolution was slightly different I wanted to add it.
In my case the issue was with Visual Studio 2017 CE on Windows 10 1903 and the symptom was a failure to run a powershell script as a post-build event even though the same powershell ran without error from the command line with the same privileges.
I was getting an exited with error 1 but could see the script was not actually being run.
VS was using the 32 bit version (not the 64 as per the accepted answer to the question) and it was that build of powershell that I'd not set the exectution policy on.
I ran PowerShell (x86) and Set-ExecutionPolicy Unrestricted, then my post-build tasks ran fine.
Answering my own question just to save others the pain of researching this.
Well http://www.vistax64.com/powershell/205436-running-powershell-post-build-event-ignoring-executionpolicy.html suggests that despite Visual Studio being 32 bit, it runs the 64 bit version of powershell which is independent.
The reality seems that Visual Studio runs the Windows\syswow64 version of Powershell (32 bit!?) while your normal Powershell command prompt will default to the Windows\system32 version (64 bit?!). You need to set execution policy etc for that separately.
(This thread is not new, but I got here from Google, so I thought sharing the solution I found would be interesting to others)
I tried changing the path to powershell.exe to "%WINDIR%\SysNative\WindowsPowerShell\v1.0\powershell.exe" and it worked perfect. The 64 bits version is called from the Post Build event and it successfully adds the SharePoint snapin.
Credits to this article: https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ff798298(v=office.14), "Using Windows PowerShell Scripts to Automate Tasks in Visual Studio".