VBA Code to check Remote Desktop Status

I would like simple VBA code that checks the status of Remote Desktop status on the remote computer FROM the remote computer.

I run an Access Database on the remote computer via a remote desktop connection. I would like the code running on the remote computer to check it's Remote Desktop Status (i.e. is the computer being logged into via remote desktop?) so that I can run different code based on the result...

...Basically, when using remote desktop to run this database I would like the application to use a different set of printers than the ones used physically at the site.  All printing is currently handled through VBA code, so if I can get code for checking Remote Desktop status, then it's just a matter of modifying the current code.
jparisoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
That you can control by selecting smart printing on the host and let the users logon with a mark in Resources, Printers. Then the session will use the user's default printer for printing. but its own default printer for a physical user.

/gustav
0
jparisoAuthor Commented:
Thanks Gustav for the quick resposne,

but...

I am not looking for a workaround here. The only solution that will be accepted is one that uses vba code.  I don't mind using API calls from the code if need be.

The reason being, specifying printing will not be the only application for this.  There are all kinds of minor functionality issues that can be modified via code if I can establish if the program itself is being run through a remote session.
0
Gustav BrockCIOCommented:
Oh, I see.

You can use:

If Environ("sessionname") = "Console" Then
    ' Console user.
Else
    ' RDP user.
End If

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jparisoAuthor Commented:
Well that was easy... and so far it works flawlessly!

Thanks for the help!
0
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.