Link to home
Start Free TrialLog in
Avatar of sunhux
sunhux

asked on

Batch script to capture month & year of current & last month to pass to a command

I currently have a Windows command line tool that could change
password with the syntax:
changepw current_password new_password

I need a batch script that'll capture the last 2 digits of the year &
month & then use it as a parameter for both current_password
& new_password so that I can change the password on the 1st
of every month in a Windows Task scheduler ie:

changepw fixedportion@AABB fixedportion@CCDD
where
- AA is the last 2 digits of last month
- BB is the last 2 digits of the year of last month
- CC is the last 2 digits of current month
- BB is the last 2 digits of the year of current month

Eg:
if currently it' s Jan 2020, then
AA = 12
BB = 19
CC = 01
DD = 20

Allow me to set in the script the
'fixedportion'  so that I can it to a
string of my preference

Can't use PS / powershell script in
our place as it's disabled so Batch
script is needed
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunhux
sunhux

ASKER

Thanks very much, Bill.

So I just need to add a line to end of the script:
changepw fixedportion@%Prior.MM%%Prior.YY%   fixedportion@%Current.MM%%Current.YY%
Exactly.


»bp