Hi,
is there a way to find out if the Administrator is logged on directly to the console of the server or via rdp to a console session.
Tried Marcus´ script to determine if console session or remote session. But that always reports console. Maybe this depends on that the admin connects to a console session.
I want to avoid that Macroscheduler start on both session the same script.
So, is there a way to find that out in MacroScheduler?
Regards,
Matthias
how to determine if real console or rdp console
Moderators: Dorian (MJT support), JRL
Having same problem
I'm having the same problem with one of my scripts. Not solved yet, but here is what I've found so far:
http://www.tech-archive.net/Archive/Win ... 00157.html
This site suggests using GetSystemMetrics to determine whether you are logged on a console or remote session. Other posts in this forum show how to use GetSystemMetrics. This site proposes using QWINSTA if you have not yet connected.
Another thing I noticed. If you run Task Manager with "Show processes from all users" turned OFF, the console session will display additional processes running as services. However you probably rather use a method that does not require displaying a GUI.
Gale
P.S. Believe this is the script Matthias tried to use
http://www.mjtnet.com/usergroup/viewtopic.php?p=11176
http://www.tech-archive.net/Archive/Win ... 00157.html
This site suggests using GetSystemMetrics to determine whether you are logged on a console or remote session. Other posts in this forum show how to use GetSystemMetrics. This site proposes using QWINSTA if you have not yet connected.
Another thing I noticed. If you run Task Manager with "Show processes from all users" turned OFF, the console session will display additional processes running as services. However you probably rather use a method that does not require displaying a GUI.
Gale
P.S. Believe this is the script Matthias tried to use
http://www.mjtnet.com/usergroup/viewtopic.php?p=11176
Last edited by gdyvig on Wed Jun 17, 2009 4:52 pm, edited 3 times in total.
Hi,
thanks to all who replied.
After playing around a little bit, i decided to use QWINSTA.exe for that.
My script now detects, if the scheduled script is exceuted under console or RDP console. So i can avoid, that a script is executed the same time under console and rdp console.
Here under Windows 2003 server and Vista it works.
Regards,
Matthias
thanks to all who replied.
After playing around a little bit, i decided to use QWINSTA.exe for that.
My script now detects, if the scheduled script is exceuted under console or RDP console. So i can avoid, that a script is executed the same time under console and rdp console.
Here under Windows 2003 server and Vista it works.
Code: Select all
let>targetFile=c:\rdptest.txt
RunProgram>cmd /c \windows\system32\qwinsta.exe %user_name% > %targetFile%
let>i=2
label>start
ReadLn>%targetFile%,i,tLine
if>tLine=##NOFILE##,NoFile
if>tLine=##EOF##,NoUser
midstr>tLine,1,8,tString
midstr>tLine,1,4,tString2
if>tString=>console,ConsoleMode
if>tString=>rdp,RdpMode
let>i=i+1
goto>start
label>ConsoleMode
messagemodal>Console Mode
Remark>put here the code, which should be executed in console mode
goto>finish
label>RdpMode
messagemodal>RDP Mode
Remark>put here the code, which should be executed in rdp mode
goto>finish
label>NoFile
Remark>Here you could place the code, which shall be executed,because QWINSTA was able not create the file
goto>finish
label>NoUser
goto>finish
label>finish
Matthias
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Just curious what you are doing with tString2?ReadLn>%targetFile%,i,tLine
if>tLine=##NOFILE##,NoFile
if>tLine=##EOF##,NoUser
midstr>tLine,1,8,tString
midstr>tLine,1,4,tString2
if>tString=>console,ConsoleMode
if>tString=>rdp,RdpMode
Should the last IF command be checkiing tString2 vs. tString ?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Hi Bob,
it should be tString2 in the last IF command, although tString2 is actually not needed, as QWINSTA produces an output, where several spaces are between sessionname and username.
I use it anyway. Maybe there are other versions of QWINSTA, which do not have that additional spaces.
Regards,
Matthias
it should be tString2 in the last IF command, although tString2 is actually not needed, as QWINSTA produces an output, where several spaces are between sessionname and username.
I use it anyway. Maybe there are other versions of QWINSTA, which do not have that additional spaces.
Regards,
Matthias