我福利局在PowerShell和在cmd中,遗憾的定义.h文件中。 我试着写脚本,它可以产生这样定义创建使用PowerShell和CMD
#define VERSION "a89aa153a054b865c0ef0a6eddf3dfd578eee9d2"
在版我想从一个源设置参数
.git\refs\heads\project
我试过未来CMD脚本,但我有问题与“字,我不能从后
echo #define VERSION \" > ver.h
type .git\refs\heads\project >> ver.h
echo \" >> ver.h
,但我有,当我试图运行一个问题。 我正在创建的文件writeDefine.ps1
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:\Scripts\DefineTemplate.txt", ForReading)
Do Until objFile.AtEndOfStream
strText = ""
strCharacter = objFile.Read(1)
If strCharacter = Chr(34) Then
Do Until objFile.AtEndOfStream
strNewCharacter = objFile.Read(1)
If strNewCharacter = Chr(34) Then
Exit Do
End If
If strNewCharacter <> "" Then
strText = strText & strNewCharacter
End If
Loop
Wscript.Echo strText
End If
Loop
objFile.Close
我想读的模板之间插入VERSION“字符和文本写入‘ver.h’,但 我有一个错误
D:\writeHeader.ps1:4 symbol:67
+ Set objFile = objFSO.OpenTextFile("D:\Scripts\DefineTemplate.txt", <<<< ForReading)
+ CategoryInfo : ParserError: (,:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingExpressionAfterToken
DefineTemplate.txt
#define VERSION ""
请帮帮我,谢谢!
您拥有的代码是vbscript,没有powershell。将其重命名为writeDefine.vbs。 –
哦,谢谢)对不起) – BergP