strName = InputBox("input you project name.")
If strName="" Then
MsgBox " can not be empty!"
wscript.quit
End If
'
' 获取本文件目录及父目录
'
scriptFullName = wscript.scriptfullname
scriptFolderPath = Left(scriptFullName, instrRev(scriptFullName, "\"))
scriptParentFolderPath = Left(scriptFolderPath, Len(scriptFolderPath) -1)
scriptParentFolderPath = Left(scriptParentFolderPath, instrRev(scriptParentFolderPath,"\"))
projectFolder = scriptParentFolderPath & strName &"\"
projectName = strName
projectFullName = projectFolder & projectName & ".vcproj"
'
' 创建文件系统操作对象
'
Set fs = CreateObject("scripting.filesystemobject")
status = True
If fs.FolderExists(projectFolder) Then
MsgBox "the project folder is exist,it will quit."
wscript.quit
End If
'
' CopySpecialfiles
'
fs.CreateFolder projectFolder
CopySpecialfiles projectFolder,scriptFolderPath,status
If status=False Then
errstr = errstr &vbCR & "CopySpecialfiles failed."
End If
ModifyProject status
If status=False Then
errstr = errstr &vbCR & "ModifyProject failed."
End If
'
' end of program
'
If errstr="" Then
MsgBox "complete successfullly"
Else
MsgBox "some error occurred" &vbCR & errstr
End If
'
'
'
Function CopySpecialfiles(targetFolderName,sourceFolderName,status)
On Error Resume Next
status = True
If Not err.number = 0 Then
err.clear
status = False
End If
End Function
'
'
'
Function ModifyProject(status)
On Error Resume Next
status = True
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = False
xmlDoc.load(projectFullName)
If Not xmlDoc.parseError.errorCode = 0 Then
status = False
err.clear
End If
strguid =""
getGuid strguid, status
If status =False Then
Return
End If
Set root = xmlDoc.documentElement
root.setAttribute "ProjectGUID", strguid
root.setAttribute "RootNamespace", projectName
root.setAttribute "Name", projectName
xmlDoc.Save(projectFullName)
End Function
'
'
'
Function getGuid(strGuid,status)
On Error Resume Next
status = True
Set TypeLib = CreateObject("Scriptlet.TypeLib")
strGuid = TypeLib.Guid
If Not err.number = 0 Then
status = False
err.clear
End If
End Function