Brian Madden Logo
Your independent source for application and desktop virtualization.
Marketplace

advertisement

Login Script Hangs, in the Scripting / Automation forum on BrianMadden.com

rated by 0 users
This post has 12 Replies | 0 Followers

Not Ranked
Points 70
Harvey Spears Posted: 05-15-2008 3:59 PM
All,

I am testing a simple vbs script I want to use to map a local drive for each TS user. The mapping is for a program to store its settings. These settings need to vary depending on the group membership of the user.

Set objShell = CreateObject("WScript.Shell")
strDrive = "B:"
strPath = "M:\FRXSettings\Test"
objShell.Run "cmd /c SUBST " & strDrive & " " & strPath, 1, True

The TS server is running on a VM machine. M: is the system drive.

I want this script to run for every user. So I configured the RDP connection settings in the Terminal Services Configuration MMC. On the Environment tab I configured the "Start the following program when the user logs on" to M:\loginfiles\fcxlogin.vbs. I checked the path and it is correct. When I login via the RDP client the login hangs and I get "An error (193) occured while creating user logon. This initial program can't be started: M:\loginfiles\fcxlogin.vbs."

I tried to correct the problem by removing that program from the Environment tab on the RDP connection settings in the TS configuration tool and by adding that program to the client settings. I get the same error when I do that.

However, when i just add that vbs script to the startup folder under the programs menu for my user then the script works just fine. Drive B: is mapped without any problems.

Does anyone have an idea what the problem might be? Any help would be greatly appreciated.

Thanks,
harvey
Top 10 Contributor
Points 26,630
The problem is you are trying to "execute" something that is not an Executable File. Change your start string to something like "CSCRIPT.EXE //NOLOGO M:\loginfiles\fcxlogin.vbs". When you do it from your Startup folder you are relying on the file association and Windows Explorer to launch the appropriate executable to run it. That isn't available when using the method you are trying to use.
DON'T FORGET TO VOTE!!!

Why is it called "Common Sense"? It doesn't seem all that common!
  • | Post Points: 20
Not Ranked
Points 70
Dan,

Thanks for the reply. I didn't think about the script not being an executable file. I did change the program line to "CSCRIPT.EXE //NOLOGO M:\loginfiles\fcxlogin.vbs" but I still get the same error. The session hangs and eventually disconnects in accordance with the settings I have setup on the TS configuration MMC. I even tried inputing the path to the CSCRIPT executable but no luck. It still hangs.

To troubleshoot the problem I tried to run notepad.exe from the RDP settings on the TS configuration MMC. I even put in the exact path to notepad. The session still hangs and terminates a few minutes later. Again I can get everything to run fine if I just put them in the startup menu for each user. As you can imagine that is not a very workable solution.

Could a group policy be fouling this up?

Any clues?

Thanks,
Harvey
  • | Post Points: 20
Top 10 Contributor
Points 26,630
Can you see the CSCRIPT.EXE process just sitting there on the server while it hangs?
DON'T FORGET TO VOTE!!!

Why is it called "Common Sense"? It doesn't seem all that common!
  • | Post Points: 20
Not Ranked
Points 45
Hello,

I have the same problem. I used this path to start the vbs script:

CSCRIPT.EXE C:\Sources\rdp.vbs (this is a vbs that writes to the eventlog)

and it works (a customized event is written to the eventlog), but after running this initial program, the session ends.

Help?!?

  • | Post Points: 20
Top 10 Contributor
Points 26,630
What else does the script do? What app are you trying to launch after the script runs?
Love the HTF icon!
DON'T FORGET TO VOTE!!!

Why is it called "Common Sense"? It doesn't seem all that common!
  • | Post Points: 35
Not Ranked
Points 45
This is what the script does:

Set objSh = CreateObject("WScript.Shell")
objSh.LogEvent 0, "RDP connection made by user."

Even a script with only a msgbox in it and started on the same way (CSCRIPT.EXE C:\Sources\messagebox.vbs) via initial program on the RDP connection settings environment tab, gives the error. You can see the messagebox after logging on via RDP, but after that the session terminates.
  • | Post Points: 5
Not Ranked
Points 45
Dan? Are you still alive?
  • | Post Points: 5
Not Ranked
Points 40
Try this

http://technet.microsoft.com/en-us/library/cc772398.aspx
  • | Post Points: 20
Not Ranked
Points 45
Thanks for your reply Willie, but that's not the problem. I know how use a policy to start a program on connection, the problem is, when the vbs is started on connection, the session gets killed because of it.
  • | Post Points: 5
Top 10 Contributor
Points 15,602
Hi,

I don't know if this will help, but you could try calling the VB script from usrlogon.cmd instead:

"cscript //nologo C:\Sources\rdp.vbs"

Alan Osborne
President (MCSE, CCNA, VCP, CCA)
VCIT Consulting - Citrix/Terminal Services Remote Desktop Solutions for SMB
p: 604-288-7325
c: 778-836-8025
web: http://www.vcit.ca
blog: http://www.vcit.ca/wordpress

  • | Post Points: 20
Not Ranked
Points 45
I'm afraid it doesn't work either...
  • | Post Points: 5
Not Ranked
Points 45
Never mind... the option start program on connection should not be used for a logonscript, because after the program (which you start on connection) ends, the session is automatically ended, I did not know that.

I resolved it by making a user-logonscript which I activated by a Group Policy on the servercontainer with the loopback option on.

In de logonscript I create a custom event, which is triggered by MOM so you get a notification e-mail when somebody logs on with RDP.

  • | Post Points: 5
Page 1 of 1 (13 items) | RSS
Copyright © 1997-2008 The Brian Madden Company, LLC | Disclosures | Privacy | Terms of Use | Contact Info