PDA

View Full Version : Setup on terminal server



tonisa
03-27-2013, 04:10 PM
Hi,
is there a simple way to avoid installation on a terminal server if it is not in install-mode (change user /install)? Is there a way to put the user in install-mode and continue with installation and put it back to execute-mode when install finishes? Actually I'm using a batch-file with
change user /install
path\setup.exe
change user /execute

best regards
Toni

linder
03-28-2013, 03:49 AM
Toni,

As far as I know, there is not really a reliable way to do this programmatically via Windows APIs. There is a "TermsrvAppInstallMode" API that determines whether the Terminal Server is in the INSTALL mode. But Microsoft clearly states that "This function is not supported and should not be used. It may change or disappear completely without advance notice."

http://msdn.microsoft.com/en-us/library/bb432494(v=vs.85).aspx

Friedrich

tonisa
03-29-2013, 04:41 AM
Hi Friedrich,
seems the only way to recognize the mode of the server is a check of the console output of a "change user /query"-command. If it contains "INSTALL" the server is in installmode, otherwise in execute. Is there a way to read the consoleoutput of a "run"-statement? Could you provide a "standard-system-function" which returns 0/1 if server is in install/execute-mode? So when running a setup on a TS in executemode the installing operator could be adviced to change the mode before installing.
best regards
Toni

linder
03-29-2013, 04:50 AM
Hi Toni,

What you easily do is to "redirect" the console output to an ASCII text file and then process (loop throught) the generated text file and see if it contains "INSTALL". You can use the "Run Command Line..." script function call the console app and the "Handle Text File Operation..." script function to process the text file.

Does this help?

Friedrich

linder
03-29-2013, 04:55 AM
Similar to this:

http://support.microsoft.com/kb/186504/en-us

change.exe user /query >mytext.txt

Friedrich

tonisa
03-29-2013, 06:26 AM
OK, I know this could be done. But it would be fine for future versions if SetupBuilder would provide a "Get System Info"-function returning the actual "users install-execute-mode"-state. So not everyone interested in this function would have to implement your mentioned "handle text file operation...".
best regards
Toni

linder
03-29-2013, 07:02 AM
Hi Toni,

The cool thing is that you can extend the SetupBuilder system with your own "include scripts". You can develop an include script and then re-use it whenever you need specific functionality.

Friedrich

tonisa
03-29-2013, 08:31 AM
Hi Friedrich,
seems there is a problem with the "redirect output"-symbol ">"; I try to set a variable like USER /QUERY >%TMPDIR%\_ts_mode.txt
but looking it contents through "display message" the part from > is truncated.
How to use the >-symbol in variables, options for run, ..?

Toni

tonisa
03-29-2013, 08:45 AM
Sorry, my mistake, the set variable to "change USER /QUERY >c:\temp\_ts_mode.txt" works fine. But when executing it through "run command line" the file is not created. I also tried with "run program" but with same result: no file there. User has rights to write to c:\temp. Same when I replace c:\temp with %TMPDIR%.
Toni

linder
03-29-2013, 09:10 AM
Toni,

As I understand it, you would like to run a console application from a Windows API (CreateProcess). So I think you are missing the cmd.exe /c in front of your call to start a new instance of the interpreter that processes the > redirection?

Something like (pseudo code):

CMD.EXE /C change.exe user /query >mytext.txt

Does this help?

Friedrich

tonisa
03-29-2013, 11:35 AM
Now with "CMD.EXE /C change.exe user /query >C:\temp\test.txt" the c:\temp\test.txt is an empty file. Executing the same command from a cmd-prompt the file is correctly created.
I tried also with "run programm", with/without ShellExecuteEx-options but the file not created or is empty. Does it work on your side?

linder
03-29-2013, 12:54 PM
Toni,

Windows APIs require a full pathname specification. So you have to add this to your CMD.EXE and CHANGE.EXE call. Otherwise, the API can't find the executables.

Friedrich

linder
03-29-2013, 12:59 PM
Similar to this:

http://www.lindersoft.com/forums/showthread.php?p=67241&post67241

Friedrich