If any of you have had the opportunity to be responsible for discovering where the bandwidth has gone can sympathize with the scenario that I was in recently. And, Im not talking about the LAN bandwidth, Im talking about the WAN bandwidth. We as a company, use roaming profiles, throw in the mix, a sales force that is constantly traveling from retail store to retail store. We had deployed Citrix as our solution, and this should have resolved our problems, did it? Apparently not, and not for the fault of Citrix, but of our users. What we discovered was happening was that our sales force would travel to a different store and log into the network as normal. Theyd fire up the Outlook icon from their desktop, and BAM, where did the bandwidth go? And, we are not talking about users with small 10-15Mb PST files. Were talking 100-200-300Mb files. And, before you scoff at us, we do realize that Exchange would be an ideal place to go. But, politics in the Corporation dictate differently. So, we are stuck for now with MS-Mail 3.5.
Luckily, these sales people were based from our Main Office. This made the Citrix solution attractive. But, how could we force them to launch Citrix when they were away from site which housed their PST files? Actually the answer was pretty simple, once we knew where to look. The answer came from the "FOR" command. I needed a command that would determine whether the server that they were logging onto was different than the one that housed their home drive. And the FOR command was the perfect solution. I wrote the following little batch file to compare the location of their APPS drive to their home drive. If they were different it forces them to launch Citrix with a preconfigured profile that launches outlook. If they were the same then it launches a local copy of Outlook. Another cool variable variation that I found was the first line, you can actually truncate the variable name to give you the amount of characters that you want. Say that I wanted the first 5 characters of the computer name, with the first line of the script, I tell it to compare the first five characters, if they match, I want it to launch a local copy of Outlook. This helped with finding out if the computer that the Outlook was being launched from was in the main site. If so, then we didnt want it to launch Citrix.
if "%computername:~0,5%" == "WCOMP" goto Outlook
for /f "tokens=2 skip=1 delims=\" %%i in ('net use p:') do (set appsrvr=%%i)
for /f "tokens=2 skip=1 delims=\" %%k in ('net use u:') do (set homesrv=%%k)
if %appsrvr% == %homesrv% then goto Outlook
Cd Program Files\Microsoft Office\Office
It still amazes me the power that one line can contain. What this command is doing is parsing out the net use p: command. If you type it at a command prompt," net use x:" where x is the letter of a mapped network drive that you have. It will display something like this.
Local name x:
Remote name \servername\sharename
Resource type Disk
# Opens 0
# Connections 1
The command completed successfully.
All the information that I need was on the 2nd line, and all I wanted was the servername portion of the line.
for /f "tokens=2 skip=1 delims=\" %%i in ('net use p:') do (set appsrvr=%%i)It obtains the information by skipping the first line, Local name, and goes to Remote Name, where it then skips the "Remote Name" portion of the line, and then uses the "\" as a delimiter. And then, I use the set command to enable a environemental variable that I can compare with the same output from the users home drive. This was an ideal solution for our problem.
If you are going to run this interactively you must use a single % sign, otherwise if its scripted, you need %%.
I hope that this helps with other peoples situations, it's nice to have powerful scripting capability at your fingertips. It just takes a little digging to find the right solution.