• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

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

0
StarfishTech
Asked:
StarfishTech
  • 3
  • 2
1 Solution
 
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
 
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
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now