1.

Solve : Net use weird behavior?

Answer»

Hello All - In a batch file I am running the net USE command to map a shared folder. I then cd to that drive and cd to the newest folder, then delete the mapped drive. When I rerun this again, the first net use statement to map the drive takes me to the last folder that I cd'd to. Why does net use behave this way? Example, my share is z: \\servername.domain.com\share\8.2\8.2.0.0.1 - the first execution takes me to the \\servername.domain.com\share\8.2\8.2.0.0.1\8.2.0.0.1.32 as expected, but the next execution takes me to the \\servername.domain.com\share\8.2\8.2.0.0.1\8.2.0.0.1.32\bin folder. So I'm not understanding why I've mapped it to a certain directory but then it seems to take it to the next level and automatically put me in the last dir I was at. That's not the behavior I am looking for....


net use z: \\servername.domain.com\share\8.2\8.2.0.0.1
z:
dir
for /f "tokens=1-4* delims= " %%A in ( ' dir /tc /ad /OD ^| find "" ^| find /V "" ' ) do if not "%%E"==".." if not "%%E"=="." set NewestFolder=%%E
Echo Newest folder is "%NewestFolder%"
cd %NewestFolder%
e:
chdir %HomeDir%
net use z: /delete
Windows remembers paths... THATS why I ALWAYS CD\. and have the batch refocus on the desired root start location and destination.



Discussion

No Comment Found