Using the %TIME% variable RRS feed

  • Question

  • Hello all,

    As part of my automated installs I have a .cmd script that creates a random variable and uses it to set the pw of the user account on the machine. To create the pw, I use the %TIME% and %RANDOM% built in variables. My problem: When I use %TIME% when setting the variable it returns the time but it has a leading space. So my password ends up having a space in it messing up the rest of my script. Anyone know why I am getting a leading space when I use the %TIME% variable. This script runs on Win7 64 bit machines. Any help appreciated.  Code to create the pw is below:

    set R1=%RANDOM%
    set R2=%RANDOM%
    set passwordVar=USERPW_%R1%_%R2%_%TIME%

    Friday, November 14, 2014 4:38 PM


  • Hey, you can trim the whitespace out pretty easily.

    If you include the below, then you can just insert %timenospace% instead of %time%

    set timenospace=%TIME%

    set timenospace=%timenospace: =%

    Friday, November 14, 2014 4:46 PM

All replies