Setting Terminal Services settings using ASP.NET (or... calling Server-side vbscript from ASP.NET)

  • Thread starter Thread starter Roja Doja
  • Start date Start date
R

Roja Doja

I need to be able to change the Terminal Services attributes.

Using vbscript on Server 2003 this is easy enough, as described at

http://www.microsoft.com/technet/scriptcenter/scripts/ts/default.mspx

for example.

I want to be able to write a web interface to do this, to make it
easier for those who will be setting these settings, and to log
changes, control access etc. However, doing the same simple task in
..Net languages (C# VB.NET etc) is proving damn near impossible. After
wrapping a Win32 API, I find I can now alter string type settings in
C#, such as TerminalServicesProfilePath, but not DWORD settings such
as MaxDisconnectionTime, which is the one I really want to be able to
change via a web interface.

As it's easy enough in vbscript, I'm wondering if there is any way I
can call a server-side vbscript plus parameters from within an ASP.NET
page?

Thanks,
Roger
 
Some of the interop stuff can get really messy. You could use the
System.Diagnostics.Process class to spin off a vbs script.
 
Of course, yes, thanks v.much. I'd even used
System.Diagnostics.Process before in an application, somehow I always
think of webserver code as different...

Anyway, just in case it's helpful, here's my working code (I don't
clainm anything, other than it works for me...) I could only get it
to work by calling cscript first, and I could only call cscript if I
set the working directory to C:\Windows\System32\ to find cscript,
rather than use the directory of the script.

Process myProcess = new Process();
myProcess.StartInfo.WorkingDirectory = @"C:\Windows\System32\";
myProcess.StartInfo.FileName=@"cscript";
myProcess.StartInfo.UseShellExecute=false;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.Arguments=@"/b
W:\Virtual\webdir\bin\myscript.vbs";
myProcess.Start();
string result = myProcess.StandardOutput.ReadToEnd();

Cheers,
Roger
 
Back
Top