0

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

Future
  • 388
  • 8
  • 21

2 Answers2

1
set timestamp=%timestamp: =-%

should set all spaces currently in 'timestamp' to dashes

Magoo
  • 77,302
  • 8
  • 62
  • 84
1

Try this:

 set timestamp="%DATE:/=-%@%TIME::=-%"
 set timestamp=%timestamp: =-%
 setx timestamp %timestamp% /K HKEY_CURRENT_USER\ENVIRONMENT
Matt Williamson
  • 6,947
  • 1
  • 23
  • 36