Mapping a drive based on system variable

Hello, we are running Windows 2003 on our terminal server. We have our users using terminal services to run an application on the server. We have their RDP session setup so that it launches a specific program when they connect to the server. Essentially, their RDP session is shelled out to this application. We would like it so that if these users RDP in to our terminal server, they get a specifc drive mapping. However we only want them to get the drive if they RDP into this server. We don't want them to get the drive if they are just logging in to a workstation. This client is using KIX32.exe to run their login scripts. In the script I have added the following statements so that when these users RDP to the server, they will get a new mapped drive. For some reason, these new statements are not mapping the drive. Any ideas on what the problem is would be greatly appreciated.

if %computername% == "server" (GOTO :true) ELSE Goto :False
:true
net use J: /delete
net use J: \\server\directory
GOTO :end
:false
Workstation not permitted J:\ mapping

:end
endif

StarfishTechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leegclystvaleCommented:
Try
IF %PCNAME%==SERVER (blah blah blah)
~cheers
0
oBdACommented:
The script you've posted is (mostly) a batch script, not a Kix script.
In batch, the correct version would be

if /i not "%ComputerName%"=="server" goto EndRDP
net use J: /delete
net use J: \\server\directory /persistent:no
:EndRDP

The Kix version is here:

If @WkSta = "Server"
  Use J: /delete
  Use J: \\Server\Share
EndIf

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
StarfishTechAuthor Commented:
OK, I've updated my KIX script and it is half working. The old J:\ drive is being deleted but the new J:\ drive is not being mapped.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

StarfishTechAuthor Commented:
If I manually run the script, I see that it complains about line 45. Says it's an invalid expression. The expression on line 45 is:

Use J: \\el-shaddai\Cleveland_Foxpro
0
oBdACommented:
Add quotes around the share path:
Use J: "\\el-shaddai\Cleveland_Foxpro"
0
StarfishTechAuthor Commented:
Worked great! Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Server OS

From novice to tech pro — start learning today.