Welcome

首页 / 软件开发 / VC.NET / 以批处理模式将Visual C++项目升级到Visual Studio .NET

以批处理模式将Visual C++项目升级到Visual Studio .NET2011-10-19 msdn 可以在命令行上运行下面的 JScript 示例,以升级一个或多个 Visual C++ 6.0 项目。

// when running this at the command line,
// call it with CScript so you don"t get UI.
// example: CScript convert.js e:yourprojectsold.dsp e:yourprojects ew.vcproj
// NOTE: full path required to both input and output files

// or set default script engine to the command line doing this first
// example: CScript //H:CScript

// Once you set the environment, run the .js file like a .bat file

// To have a batch file loop through all the .dsp files
// in a directory, write a batch file that looked like this
// (Windows NT 4 or Windows 2000 only)
// CScript //H:CScript //Nologo
// for /R %%i in (*.dsp) do convert.js %%i >> .Convert.log

var vcProj = new ActiveXObject("VisualStudio.VCProjectEngine.8.0");
var objFile = new ActiveXObject("Scripting.FileSystemObject");
var objArgs = WScript.Arguments;

// check the arguments to be sure it"s right
if (objArgs.Count() < 2)
{
WScript.Echo("VC6 or 5 DSP Project File Conversion");
WScript.Echo("Opens specified .dsp and converts to VC8 Format.");
WScript.Echo("Will create project file with .vcproj extension");
WScript.Echo(" usage: <full pathproject.dsp> <full pathproject.vcproj>");
WScript.Quit(1);
}

WScript.Echo(" Converting: "+ objArgs.Item(0));
// If there is a file name of the .vcproj extension, do not convert
var vcProject = vcProj.LoadProject(objArgs.Item(0));
if (!objFile.FileExists(vcProject.ProjectFile))
{
// specify name and location of new project file
vcProject.ProjectFile = objArgs.Item(1);

// call the project engine to save this off.
// when no name is shown, it will create one with the .vcproj name
vcProject.Save();
WScript.Echo("New Project Name: "+vcProject.ProjectFile+" ");
}
else
{
WScript.Echo("ERROR!: "+vcProject.ProjectFile+" already exists! ");
}