私は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
また、その投稿のスクリプトを使用してみましたhttp://blogs.technet.com/b/heyscriptingguy/archive/2008/04/29/how-can-i-read-a-text-file-and-extract- all-the-text-enclosed-in-double-quote-marks.aspx
しかし、それを実行しようとすると問題が発生します。私はファイル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 ""
私を助けてください。ありがとう!