Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1994
  • Last Modified:

TSWEB remote desktop connection running a .bat file

Greetings experts.
I have a W2003 server that has TSWEB configured.  I can access the server via the internet using the TSWEB interface.  I would like to acheive the following:
Once the user logs in via RDC or TSWEB, I need a .bat file to run that eventually starts a java application.  Now the .bat file named RunDesktop.bat basically just starts an application.  Instead of the user having to login then start the application; if I could figure out how this works, once the user logs in the app would start automatically.  This needs to work regardless if the user logs in using traditional RDC (terminal services) or the TSWEB (via internet).  Can this be done?  If so please give detailed specifics.  Thanks.  More info will follow if necessary.
0
EaglePress
Asked:
EaglePress
  • 7
  • 5
1 Solution
 
LucFCommented:
Hi EaglePress,

Terminal server has a system login script which is applied to all users. This is the USRLOGON.CMD in %systemroot%\system32 directory.
Add the lines needed to start your application and you'll be fine.

Greetings,

LucF
0
 
EaglePressAuthor Commented:
Here is the RunDesktop.bat code
>>>>>>>>>>>>>
REM @echo off
cls

rem ====================================================================
rem ================ VersionChecker - check for updates ================
rem ====================================================================
call "C:\_ACI\CERT\VersionChecker\verChk" "C:\_ACI\CERT\ES\Desktop\local.cfg"
start "Desktop Console" DesktopLauncher
rem pause
>>>>>>>>>>>>


Here is the USRLOGON.CMD from the server that i am accessing.  Where would i place the code to start my logon application?
>>>>>>>>>>>>>
@Echo Off

Call "%SystemRoot%\Application Compatibility Scripts\SetPaths.Cmd"
If "%_SETPATHS%" == "FAIL" Goto Done

Rem
Rem This is for those scripts that don't need the RootDrive.
Rem

If Not Exist "%SystemRoot%\System32\Usrlogn1.cmd" Goto cont0
Cd /d "%SystemRoot%\Application Compatibility Scripts\Logon"
Call "%SystemRoot%\System32\Usrlogn1.cmd"

:cont0

Rem
Rem Determine the user's home directory drive letter.  If this isn't
Rem set, exit.
Rem

Cd /d %SystemRoot%\"Application Compatibility Scripts"
Call RootDrv.Cmd
If "A%RootDrive%A" == "AA" End.Cmd

Rem
Rem Map the User's Home Directory to a Drive Letter
Rem

Net Use %RootDrive% /D >NUL: 2>&1
Subst %RootDrive% "%HomeDrive%%HomePath%"
if ERRORLEVEL 1 goto SubstErr
goto AfterSubst
:SubstErr
Subst %RootDrive% /d >NUL: 2>&1
Subst %RootDrive% "%HomeDrive%%HomePath%"
:AfterSubst

Rem
Rem Invoke each Application Script.  Application Scripts are automatically
Rem added to UsrLogn2.Cmd when the Installation script is run.
Rem

If Not Exist %SystemRoot%\System32\UsrLogn2.Cmd Goto Cont1

Cd Logon
Call %SystemRoot%\System32\UsrLogn2.Cmd

:Cont1

:Done
>>>>>>>>>>>>>>>
0
 
LucFCommented:
Your best location might be to add it just after ":Done" to make sure all of the login script is completed before launching the application. So the end of your loginscript will either look like:
-=-=-=-=-=-
:Done
<insert the path to the file>\RunDesktop.bat
-=-=-=-=-=-

or

-=-=-=-=-=-
:Done
call "C:\_ACI\CERT\VersionChecker\verChk" "C:\_ACI\CERT\ES\Desktop\local.cfg"
start "Desktop Console" DesktopLauncher
-=-=-=-=-=-

See what you like most, if you want the files seperate, or if you want to include rundesktop.bat into the login script.

LucF

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
EaglePressAuthor Commented:
sorry for the delay in responding.  I tried modifying the usrtlogon.cmd file with no success.  I have been doing some brain-storming w/ my team and we have, hopefully, came up with another solution that might work better, but we still need assistance in implementation.

Instead of using TSWEB or an terminal services rdc connection we will use only TSWEB.  This will negate having to support terminal services and the tsweb.  One less piece in the puzzle. Now the TSWEB link needs to be able to run the RunDesktop.bat file whenever the webpage is accessed.  I guess this is similar to launching an .exe file when a web page is started.  Can this be done?  if so what are the procedures.  I would think that the c:/winnt/web/tsweb/default.html file could be modified to include the RunDesktop.bat file to launch upon accessing.
0
 
LucFCommented:
I've just started playing around a little, and I also have problems with the usrlogon workaround... sorry about that.
Browser security won't allow you to run .exe or .bat files unless they're located on the client computer. How's this all setup?

Is it possible for you to run this batch from "Startup" in the start menu? If so, this will make sure it's started right after the terminal has been fully logged into.

(I have to test this all on my homeserver, on which TS is setup as "Remote Administration", it might make a difference)

LucF
0
 
EaglePressAuthor Commented:
Well, we actually thought about that, (running it from the startup folder).  Right now that is not an option.  If its in the startup then every user that logs on will run the application.  There will abe approx. 100 users that need access to the application.  BUt the kicker is I dont want this application to runn when any user from the administrator group logs on.  Is there a work around for that?   I really approciate the assistance with this.
0
 
LucFCommented:
I'm not sure if that's an option with TS, I'll ask someone who knows a little more about TS if he's able to help you.

LucF
0
 
LucFCommented:
Seems like he's not online at the moment, I hope he'll post here when he gets the message, but in the time between:
All different TS profiles are stored at C:\Documents and Settings\%username%\
From there it was easy for me to make different startup entries for everyone.
C:\Documents and Settings\%username%\Start Menu\Programs\Startup\ worked for me in both normal login and Terminal Services, so if you liked this approach, it might suit you well.

LucF
0
 
EaglePressAuthor Commented:
Looks like we are going to have to make additional modifications to the user group that accesses this server via TSWEB.  I can get the startup for each user to start the application, but if they close the application the TS desktop is visible.  I guess our next option is to lock down the TS so only the application is accessible.  I will pass this along to the active directory group.  Thansk for you assistance.  I will keep this posting open for a few days to see if anyone else has additional input.
0
 
LucFCommented:
If that's all that is needed, to run only a single application, take a look at the following page:
Using Windows Terminal Services to Run a Single Application
http://www.windowsecurity.com/articles/Windows-Terminal-Services-Run-Single-Application.html

It'll help you locking down the TS so it runs only one application and logs the user off when the application is closed.

LucF
0
 
EaglePressAuthor Commented:
I think that will work.  Thanks for the information.  
0
 
LucFCommented:
You're very welcome :)
Thanks for the grade!

LucF
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now