質問

I am using this code to create an environment variable with the current date and time:

setx timestamp "%DATE:/=-%@%TIME::=-%"

The effect of using this command is to create a string value "timestamp" in HKCU\Environment with the data value "Fri 26-04-2013@18-32-31.29".

What i want is to remove that space from "FRI" and "26-04-2013@18-32-31.29" to make it "Fri-26-04-2013@18-32-31.29".

Thanks

役に立ちましたか?

解決

Try this:

 set timestamp="%DATE:/=-%@%TIME::=-%"
 set timestamp=%timestamp: =-%
 setx timestamp %timestamp% /K HKEY_CURRENT_USER\ENVIRONMENT

他のヒント

set timestamp=%timestamp: =-%

should set all spaces currently in 'timestamp' to dashes

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top