|@rev.. Note what Razor Said..|
- You're not assigning %UserName%, you're assigning %UserName % (note the space).
See this line now.
set /p UserName =Enter your username...
See the space between "UserName and = " Remove this space and it will work fine..
Your current script treats the current loged in user as Username and try to match
if /i "loginusername" == User1 goto MKT
if /i "loginusername" == User2 goto FIN
Both of above are evulated as false so the command interpreter goes to next steps which is to execute the script in lable :mkt
Also, Razor mentioned that if someone enters user3 , it will also do the same thing. i slightly modified it ..try it..
net user user1 /add
net user user2 /add
set /p UserName=Enter your username...:
if /I "%UserName%" == "user1" (
net share Mark=C:/Users/user1/Marketing
net use S: \\localhost\Mark
if /I "%UserName%" == "user2" (
net share Finan=C:/Users/user2/Finance
net use T: \\localhost \Finan
Echo. You have entered an invalid value .
What i dont understand is , Why you want to share a local folder and then map it as a new drive ?
You can use subst Drivename: Path to map a folder as drive..