MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
@ECHO OFF REM Clear Screen of information cls REM Prompt for username:uname :uname REM If username is blank go to Error prompt. If username is entered prompt for password SET /P uname=Please enter your username: IF "%uname%"=="" (goto uNameError) else (goto password) REM prompt for password :password REM this will mask password that is being entered @echo off set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; ^ $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^ [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"" for /f "usebackq delims=" %%p in (`%psCommand%`) do set passwd=%%p IF "%passwd%"=="y" (goto passwdError) else (goto rasdial) REM If password is blank go to password Error prompt. If password is entered start dialing VPN connection REM SET /P passwd=Please enter your password: REM IF "%passwd%"=="y" (goto passwdError) else (goto rasdial) REM Dialing VPN COnnection :rasdial Echo Trying to connect to VPN................ rasdial VPN %uname% %passwd% REM If VPN connection is not successful, error message will be displayed if NOT %ERRORLEVEL% ==0 (goto failed) else (goto mapDrive) REM Prompt to retry VPN connection ir exit :failed SET /P rasFailed=Failed to connect......Retry? (y or press n then enter to exit): IF "%rasFailed%"=="y" (goto uname) else IF "%rasFailed%"=="n" (goto end) REM Network Drive connections :mapDrive net use w: \\Server\database /user:%uname% %passwd% /Persistent:no goto disconnectQ REM Username is Blank Error MEssage :uNameError ECHO You did not enter a username. SET /P unameretry=Retry? (y, then enter or press enter to exit): IF "%unameretry%"=="y" (goto uname) else (goto end) REM Password is Blank Error Message :passwdError ECHO You did not enter a password. SET /P passRetry=Retry? (y, then enter or press enter to exit): IF "%passRetry%"=="y" (goto password) else (goto end) REM Propmt for disconnection from VPN :disconnectQ @echo off SET /P disconnectQ=Are you ready to disconnect? IF "%disconnectQ%"=="y" (goto logoffVPN) else goto disconnectQ REM Disconnect Mapped VPN Drive and then disconnect from VPN :logoffVPN net use w: /delete rasdial VPNName /DISCONNECT :end
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.