Sardis
(Fresh Scripter)
2004-01-19 11:04 PM
Terminal Services Scripting

Hello, I am using KiX ver 4.22 under Windows 2000 Server letting all my users login to the terminal server. All scripts are run through group policies in AD users and computers. I have made a script the deletes all network connections when a user logs out and it works fine, however, I got another script from this bullitan board that allows me to pop-up a random quote from a text file. If I add the code to the small network connection delete script I wrote earlier, the new script works fine, but the delete connections script happens on logoff. If I put it in the logon section, the new code never appears to work. If I add the script to execute AFTER the network connections deletion script runs, the terminal hangs during logoff and will not be released until I manually release it using terminal services manager. DOes anyone know what this is all about?

Sealeopard
(KiX Master)
2004-01-19 11:49 PM
Re: Terminal Services Scripting

You're not providing enough information. Most likely it's messed-up code. Run the scripts with DEBUG ON to step throught he code and see where it fails.

Sardis
(Fresh Scripter)
2004-01-20 12:01 AM
Re: Terminal Services Scripting

I have run the code in debug, I can't find out where it errors out, it's like it just stops. What can I do?

Sealeopard
(KiX Master)
2004-01-20 12:07 AM
Re: Terminal Services Scripting

Now, if you've run the code in debug mode, then you'd know which was the last line that got executed correctly, wouldn't you, as the executed lines get displayed in the console?

So, then take a look at the last line that got executed and the line after. Also, make sure that all strings are correctly enclosed in quotes and all conditional statements are closed correctly. It migth also help to start a script with
Code:

$rc=setoption('explicit,'on')
$rc=setoption('novarsinstrings','on')



Finally, it helps to post the code when asking why a particular piece of code does not work.


Glenn BarnasAdministrator
(KiX Supporter)
2004-01-20 05:22 AM
Re: Terminal Services Scripting

Jens:

Ya had me scratching my head for a few moments.. that's dangerous, because I keep expanding the bald spot.

Anyway, you might want to clarify that "strings of text" (<= like this one) should be enclosed in matching quotes, but String Variables should not. This is especially important if you turn on the NoVarsInStrings option.

Sardis:
When I'm troubleshooting a script, I usually only turn one option at a time on - usually EXLICIT is done first. Otherwise you might be overwhelmed with error messages AND wierd output.

Another thing I do when writing or debugging code is identify the EndIf statements, as such:
Code:
 

If $RC = 0
'OK!' ?
Else
'Fail!' ?
EndIF ; $RC = 0


This helps locate missing EndIfs (or loops, too).

Finally, I sprinkle little print statements through the code where I suspect the problem might be, even something so simple as Code:
 '.' 

, which prints a series of dots. I can count the dots and know what line I made it to before the script ended.

Glenn


Kdyer
(KiX Supporter)
2004-01-20 02:45 PM
Re: Terminal Services Scripting

Lastly, if you want, you can download a parser like KiXStrip from MCA's site to check your code as well. It will also check for missing ENDIFs, LOOPs too..

But, with the talent lurking around here, if you post your code, you should have a response in oh about 10 minutes (no joke)..

Kent


Sealeopard
(KiX Master)
2004-01-20 04:26 PM
Re: Terminal Services Scripting

The funny thing is, we even invested the time and effort to create FAQs dealing with debugging, e.g. Debugging script without user input. also during logging on. the advanced way and Debugging without user input .