How to get username into a batch file on Windows 98/95
Posted on 2002-03-13
Our users log on to our Windows NT domain whenever they begin using a Windows 95/98/NT or 2000 computer. Normally our logon script, running on the PDC, maps certain drives to shares on our NT server whenever someone logs on to the network. However, we have been seeing, intermittent, seemingly random cases where this automatic mapping is not occuring. It is difficult to troubleshoot because when we WANT the problem to happen so we can analyze it, mapping always works fine.
As a workaround, I want to make a batch file that the users can run when this happens. The batch file would use the net use command to map these drives. I could make a separate batch file for each user who logs on at each computer but that would be very tedious for the number of users I support. I would prefer to use the sytax below:
net use X: \\servername\%username%
so that the actual username would automatically be filled in. This works on Windows NT and 2000, but Windows 98 and 95 do not automatically set this variable. Does anyone know of a way or utility that will allow a batch file running on a Windows 98/95 machine to get the username?