Goal is to do the following using batch script:
My system's hostname is: W0000000000ZQ
My batch script looks like this:
@echo off
hostname>hostname.txt
CertUtil -hashfile hostname.txt SHA256 //<- this is generating wrong sha256 string because
// the above generated file contains CRLF and a new line
// screenshot of this file provided below.
CertUtil -hashfile hostname-manual.txt SHA256 //<- this is generating correct sha256 string because
// i manually created this file and pasted hostname
// only (W0000000000ZQ) without CRLF and new line.
// screenshot of this file provided below.
hostname.txt:
hostname-manual.txt
Output from the script:
Can you please suggest how to remove CRLF and a newline from "hostname.txt" so that Certutil will pick correct string to generate sha256 value.
下面将主机名保存到一个没有尾随 CRLF 的文件中。
for /f %%h in ('hostname') do (>hostname.txt <nul set /p unused=%%h)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.