Due to the uselessness of the IT team in my place of work, I have written a small batch file for the people in my department to map a network folder to a drive letter since the network path is too long and Windows will not allow us to open any files in that folder or any of it's subfolders. I have the batch file on my memory stick since our e-mail system blocks batch files, reading them as malicious so I can't e-mail it to everyone. This is the only thing on my memory stick that I will need to open/run while at work so I was wondering:

Is it possible to make the autorun.inf only run when connected to a certain domain or workgroup?

Try this conditional batch.

echo off
if %username% == somename net use x: \\server\share

You will have to add an if statement for each user. I cannot figure out how to find domain from vars, but usernames have similar effect.

That should work, it would just mean the batch file is longer than I originally thought.

Just one question:

Is the username case sensitive?

Here is a simple test.

echo off
if %username% == BoRzOi echo isnt case sensitive
pause

Replace BoRzOi with the real username in the same case format.

-Ryan

I know how to test it but I can't until I get into the office which is why I asked if anyone knew. I can't get into the office today due to snow because the bus company here sees snow and thinks "We can't go on!" like it's a perilous journey.

I know how to test it but I can't until I get into the office which is why I asked if anyone knew. I can't get into the office today due to snow because the bus company here sees snow and thinks "We can't go on!" like it's a perilous journey.

any luck?

The batch file works but I forgot to test the case sensitivity. I'm going to mark this thread as solved but I'll post the results in here when I've tested it; which should be tomorrow but don't quote me on that.

The username IS case sensitive.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.