While using OpenSSL on Windows:
openssl genrsa -out privatekey.pem 1024 -->
Created successfully
openssl req -new -x509 -key
After installing OpenSSL, you need to restart your computer and use Run As Administrator. Then its works.
Run As Administrator