Pergunta

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

Foi útil?

Solução

Try this:

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

Outras dicas

set timestamp=%timestamp: =-%

should set all spaces currently in 'timestamp' to dashes

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top