VMware Horizon Community
MAHC
Enthusiast
Enthusiast
Jump to solution

Old Hardware & VDI

OK I am running into another road block. I am planning on using my old hardware (Dell GX260 to the Optiplex 745) but how do I get it so the user only needs to log in once rather than at 2 sections (Windows log in and then the VDI log in). I would like the device to boot directly to the VDI Log in. Is that possible and how? I am looking at going to thin clients in the future but at this time it is to use the old hardware. I have looked into the auto log in for windows but I don't like that as an option because then there is an opening into the network for potential troubles.

0 Kudos
1 Solution

Accepted Solutions
sgrinker
Hot Shot
Hot Shot
Jump to solution

Here, let's try this. I've attached the VBS file. Hopefully that comes through ok!

View solution in original post

0 Kudos
22 Replies
TomHowarth
Leadership
Leadership
Jump to solution

if you use Autologin and have a tied down internet explorer with the web-address of the VDM connection server as the home address, do not set a DNS connection for the local machine and enter the VDM connection server in the Host file. you will boot your guest, auto login and load IE as the default shell which auto loads the connection server website.

Tom Howarth

VMware Communities User Moderator

Tom Howarth VCP / VCAP / vExpert
VMware Communities User Moderator
Blog: http://www.planetvm.net
Contributing author on VMware vSphere and Virtual Infrastructure Security: Securing ESX and the Virtual Environment
Contributing author on VCP VMware Certified Professional on VSphere 4 Study Guide: Exam VCP-410
MAHC
Enthusiast
Enthusiast
Jump to solution

Now when you say to go to a web browser and view the VDM webpage I go to a management page rather than the desktop (VDI) itself. Is there another method of viewing the virtual desktop through the web browser rather than the VDI client?

0 Kudos
mittim12
Immortal
Immortal
Jump to solution

In my case to access the management page I use . To access the workstation pool I removed the admin from the link.

If you found this or any other post helpful please consider the use of the Helpfull/Correct buttons to award points

MAHC
Enthusiast
Enthusiast
Jump to solution

Both the option i am using now with the client and the web client (cool by the way) will work to get to the desktop but what I want to avoid is having the risk of the computer staying logged in because the user logs off the VDI desktop and not the hardware one. Is there a way to remove that possible step so they only have to log off once.

0 Kudos
sgrinker
Hot Shot
Hot Shot
Jump to solution

You could write a startup VBS script to watch for an event (or process ending) and then log off the host OS. I known it's not exactly straight forward, and unfortunately I don't have a great concrete example to show you what I mean. We do run something similar for a Citrix session. It watches for the WFICA32.EXE process to close using WMI, and then logs the user off of the desktop. Although with Citrix, that process will close when the session ends... I can't think of any process to watch with this example. Beyond that we lock down the local host machine with GPO pretty tight. At least that way you wouldn't have to worry as much if a host machine is left logged on. Lock it down so only IE can launch, and can only browse to the site you need. Again nothing concrete (or necessarily straight foward), bust just throwing out some ideas "outside of the box" so to speak. Smiley Happy

Thanks

Steve

0 Kudos
TomHowarth
Leadership
Leadership
Jump to solution

MSTSC.EXE perhaps?

Tom Howarth

VMware Communities User Moderator

Tom Howarth VCP / VCAP / vExpert
VMware Communities User Moderator
Blog: http://www.planetvm.net
Contributing author on VMware vSphere and Virtual Infrastructure Security: Securing ESX and the Virtual Environment
Contributing author on VCP VMware Certified Professional on VSphere 4 Study Guide: Exam VCP-410
0 Kudos
MAHC
Enthusiast
Enthusiast
Jump to solution

I did a little looking to confirm my thoughts but mstsc.exe is used for remote desktop and I don't see how it would do what I need? I am looking to have the base system (Windows XP SP2) get shut down when the VDI client is closed. I might use IE since that seems to also be popular in previous posts. If I am looking at this wrong please explain it a bit more if you could.

I am also think about setting up a base system with Linux if that would be easier to create this script for I am up for considering it but I would still need help writing the script.

Thanks,

0 Kudos
mittim12
Immortal
Immortal
Jump to solution

The VDM client connects to the guest OS over RDP so in theory when you disconnect and logoff through the VDM client then the mstsc.exe process should end.

0 Kudos
MAHC
Enthusiast
Enthusiast
Jump to solution

I think that the WSWC.exe file also would work to reference to but Is there a way to do this? I will use the mstsc.exe if that is better :). I have been told to look at scripts and also to consider Linux but unfortunately I have no idea how to script this or if there is a 3rd party utility that can do this on either Linux or windows. Any thoughts?

0 Kudos
sgrinker
Hot Shot
Hot Shot
Jump to solution

Duh, MSTSC.EXE... Thanks, Tom!

0 Kudos
sgrinker
Hot Shot
Hot Shot
Jump to solution

Funny you should ask... I was just about to post this example for you using MSTSC.exe. You can change the process it looks for at the top of the script, by changing strProcess. Then you'll need to execute this script at startup/logon, and play with the timing to make sure that the "watching" doesn't start until the process is executed. Once the process is gone, it will then log off.

-


START OF CODE

-


On Error Resume Next

'#####################

'Wait a short time to allow the process to start, assuming it's an auto-launch process.

'Monitor for the process existing.

'If the Process exists, continue to monitor; waiting 2 seconds between each check

' If you don't put a 'wait' in there, it'll hog 100% of the CPU just to monitor.

'If the Process does not exist, exit the monitoring process, and logoff the user

'##############################

Set sho = Wscript.CreateObject("Wscript.Shell")

strComputer = "."

strProcess = "mstsc.exe"

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!
" & strComputer & "\root\cimv2")

wscript.sleep 36000 'wait several seconds before starting this script to allow process time to launch

Do while i=0

wscript.sleep 1200 '1=1ms, so 600=1 second

Set colProcesses = objWMIService.ExecQuery _

("Select * from Win32_Process Where Name = '" & strProcess & "'")

If colProcesses.Count < 1 Then

sho.LogEvent 4, "Remote Session Terminated"

i=1

Else

'Do Nothing, it's a running process

End If

Loop

sho.run "shutdown -l",0,False 'This time it's FALSE because we want the script to exit regardless of the logoff.

wscript.quit

-


END OF CODE

-


0 Kudos
TomHowarth
Leadership
Leadership
Jump to solution

Well, Steve you have just stole my thunder again Smiley Wink I was just about to post something similar.

Tom Howarth

VMware Communities User Moderator

Tom Howarth VCP / VCAP / vExpert
VMware Communities User Moderator
Blog: http://www.planetvm.net
Contributing author on VMware vSphere and Virtual Infrastructure Security: Securing ESX and the Virtual Environment
Contributing author on VCP VMware Certified Professional on VSphere 4 Study Guide: Exam VCP-410
0 Kudos
sgrinker
Hot Shot
Hot Shot
Jump to solution

hahaha... again? I didn't known this has been a trend. Smiley Happy Nothing intentional of course though. What can I say, great minds think alike. :smileygrin:

0 Kudos
MAHC
Enthusiast
Enthusiast
Jump to solution

I am very grateful of all the help you both have been giving but I am having one small issue..I think mostly because I am having a dumb day but anyways i copied the script sgrinker has shared but it gives me no results. The section of code I had copied is shown below. I also tried it with other processes to see if maybe that was the issue. I saved the file as wscript.vbs and also tried a different name vdi.vbs. What am I doing wrong?

On Error Resume Next

'#####################

'Wait a short time to allow the process to start, assuming it's an auto-launch process.

'Monitor for the process existing.

'If the Process exists, continue to monitor; waiting 2 seconds between each check ' If you don't put a 'wait' in there, it'll hog 100% of the CPU just to monitor.

'If the Process does not exist, exit the monitoring process, and logoff the user '############################## Set sho = Wscript.CreateObject("Wscript.Shell")

strComputer = "."

strProcess = "mstsc.exe"

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!
" & strComputer & "\root\cimv2")

wscript.sleep 36000 'wait several seconds before starting this script to allow wfica32.exe time to launch

Do while i=0

wscript.sleep 1200 '1=1ms, so 600=1 second

Set colProcesses = objWMIService.ExecQuery _

("Select * from Win32_Process Where Name = '" & strProcess & "'")

If colProcesses.Count < 1 Then

sho.LogEvent 4, "Remote Session Terminated"

i=1

Else

'Do Nothing, it a running process

End If

Loop

sho.run "shutdown -l",0,False 'This time it's FALSE because we want the script to exit regardless of the logoff.

wscript.quit

0 Kudos
sgrinker
Hot Shot
Hot Shot
Jump to solution

No worries... The script won't envoke the VDI session, all the script does is watch for the existence of whatever process you specify. Once that process no longer is running, it will log the current user off. So basically if you tell it to watch for MSTSC.exe, you need to have that process running. The process SHOULD be running once the RDP session has been started. Then you'll need a means of executing the VBS script (I'd stick with a name similar to the VDI.vbs you specified below). The script uses WMI to check if the process is still running. Once it detects that the MSTSC.exe process has been closed it will log off the user.

You can test this by simply changing the process to notepad.exe. Then launch notepad, run the script, wait a bit for the script to start "watching", close notepad, and you should be logged off of the computer shortly after.

Again, hope this helps...

Thanks

Steve

0 Kudos
MAHC
Enthusiast
Enthusiast
Jump to solution

OK I changed the process to notepad.exe and then I fire off notepad and then the script and I let it run for about 5 min. Once I close note pad i do notice that wscript closes out of task manager and i am not logged out. I did do like you said and named the script VDI.VBS. Is there something i have to do with WMI to make this work? I also tried it on 2 systems. 1 with nothing on it but windows and the device I am working on now. What would be preventing it from executing the log off command?

0 Kudos
sgrinker
Hot Shot
Hot Shot
Jump to solution

Alright, for some reason, maybe notepad.exe was a bad example. I just tested that and was having strange results. Here's a bit of an updated script that I confirmed works here for Internet Explorer. Same things applies, launch IE, launch script, wait a bit, and then close IE. You should be logged out. If it doesn't work, cofirm that the logoff command lines works on your machine. Run "shutdown -L" from a command prompt.

-


NEW CODE

-


On Error Resume Next

'#####################

'Wait a short time to allow the process to start, assuming it's an auto-launch process.

'Monitor for the process existing.

'If the Process exists, continue to monitor; waiting 2 seconds between each check

' If you don't put a 'wait' in there, it'll hog 100% of the CPU just to monitor.

'If the Process does not exist, exit the monitoring process, and logoff the user

'##############################

Set sho = Wscript.CreateObject("Wscript.Shell")

strComputer = "."

strProcess = "iexplore.exe"

i=0

Set objWMIService = GetObject("winmgmts:
" & strComputer & "\root\cimv2")

Set objShell = CreateObject("Wscript.Shell")

'wscript.sleep 36000 'wait several seconds before starting this script to allow process time to launch

Do while i=0

wscript.sleep 1200 '1=1ms, so 600=1 second

>Set colProcesses = objWMIService.ExecQuery _

("Select * from Win32_Process Where Name = '" & strProcess & "'")

If colProcesses.Count = 0 then

sho.LogEvent 4, "Remote Session Terminated"

i=1

Else

'Do Nothing, it's a running process

End If

Loop

0 Kudos
sgrinker
Hot Shot
Hot Shot
Jump to solution

Might be a problem because the page keeps screwing up my formatting....!!!!

The following SHOULD be on one line:

Set objWMIService = GetObject("winmgmts:" & strComputer & "\root\cimv2")

0 Kudos
sgrinker
Hot Shot
Hot Shot
Jump to solution

Also...

Set colProcesses = objWMIService.ExecQuery _

("Select * from Win32_Process Where Name = '" & strProcess & "'")

Is getting messed up becauase I can't find a "<code>" tag on here... check out the following link for an example of how this line should be formatted.

0 Kudos