Brian Madden Logo
Your independent source for application and desktop virtualization.
advertisement

VBScript to Launch Desktop Automatically, in the Scripting / Automation forum on BrianMadden.com

rated by 0 users
Answered (Not Verified) This post has 0 verified answers | 5 Replies | 3 Followers

Not Ranked
Points 215
Anthony posted on Thu, May 28 2009 9:55 AM

I am trying to convert our old PC's to thin clients.

The easiest way (free) I found was to leave Windows XP on PC's and have the PC launch PN.exe using a VBscript.  I have changed HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Shell from Explorer.exe to wscript "C:\Program Files\Citrix\ICA Client\vbscript.vbs" to run the vbscript as soon as the user logs on to the PC.  When the user logs off their session I want the computer to log off too.

This is the script that I am using:

 

 

 

 

 

Dim WshShell

set

 

WshShell = CreateObject("WScript.Shell")

Wshshell.Run

"""c:\Program Files\Citrix\ICA Client\pn.exe"" /APP ""Desktop""", 1, True

WshShell.Run

"c:\WINDOWS\system32\psshutdown.exe -o"

The problem that I am having is that the psshutdown.exe runs automatically eventhough the previous Wshshell.Run states pause script and continue after the pn.exe is closed. 

If I remove /APP "Dekstop" the script works great but I want the desktop to appear automatically without the user having to see the Program Neighborhood window.

Any help would be appreciated.

  • | Post Points: 50

All Replies

Not Ranked
Points 70
Answered (Not Verified) miks replied on Sun, May 31 2009 8:35 PM
Suggested by miks

you could try  tasklist to find a process  (eg wfica32.exe)

to use  in a  do - while loop, ev. including a wscript.sleep 100

after launching the "desktop".

 

windows xp has shutdown.exe and tasklist.exe integrated

 

 

  • Post Points: 5
Top 10 Contributor
Points 24,510

I would change [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] as follows:

"DefaultUserName"="insert_username_here"
"AutoAdminLogon"="1"
"AutoLogonCount"=dword:ffffffff
"Userinit"="c:\\windows\\system32\\userinit.bat,"
"DefaultPassword"="insert_pwd_here"

Save this to a REG file and deploy. That will ensure that all users logging in to the workstation are forced to use PN client as the shell.

Here's a sample userinit.bat file:

c:
cd \%systemroot%\system32
cscript %systemroot%\system32\disclaimxp.vbs

And a sample disclaimxp.vbs file:

Dim WshShell, BtnCode, strCmd

strCmd = "%comspec% /c ""C:\Program Files\Citrix\ICA Client\pn.exe"" /APP ""Desktop"""
Set WshShell = WScript.CreateObject("WScript.Shell")

strSystemRoot = WshShell.ExpandEnvironmentStrings("%SystemRoot%")

Do
BtnCode=WshShell.Popup("Insert disclaimer text here or NO to shutdown your computer", 0, "Please acknowledge and read this disclaimer", 4 + 32)

'Exit code values - Y is a 6, N is a 7

IF BtnCode=6 then WshShell.Run strCmd,3,True
If BtnCode=7 then WshShell.Run "shutdown -s -f -t 0",3,TRUE
Loop

Alan Osborne

President (MCSE, CCNA, VCP, CCA)

VCIT Consulting - Citrix/Terminal Services Remote Desktop Solutions for SMB

VCIT website My Blog

  • | Post Points: 20
Not Ranked
Points 215

Thanks for your help guys.

I decided to search for the wfica32.exe in my vbscript.  The script will be in a continuous loop until the wfica32.exe is closed.  After that, I use a shutdown command to log off the user.  The script is below.

Dim WshShell
set WshShell = CreateObject("WScript.Shell")

Wshshell.Run """c:\Program Files\Citrix\ICA Client\pn.exe"" /APP ""Desktop""", 1, True

Process_Checker = True
Found_it = False
Counter = 0  
wscript.sleep 1000

Do
   
 Set wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_Process")
  
 For Each wmiObj In wmiColl
   
  If LCase(wmiObj.Caption) = "wfica32.exe" Then
   Found_it = True
  End If
  
 Next
  
 If Found_it <> True Then
 
  Process_Checker = False
  
 End If 
 
 Counter = Counter + 1
  
 Found_it = False
 
 wscript.sleep 2000
  
Loop Until Process_Checker = False

Call WshShell.Run("shutdown -l", 1, True)

Once again, thanks for your help.

  • | Post Points: 20
Top 500 Contributor
Points 838
Marco replied on Wed, Jul 22 2009 10:10 AM

Hi,

try and have a look at thinstation OS. Its free and easy to implement.

greetings,
Marcus

 

  • | Post Points: 5
Not Ranked
Points 5
Suggested by 3rdworldwar

Can somebody please suggest a code (vbscript peferably) to display the 'About Program Neighborhood' window? pn.exe displays the 'Program neighborhood' window.

Or if anybody can suggest code in Vbscript to display the Citrix version number, it will be more than welcome.

 

Thanks in advance.

  • Post Points: 5
Page 1 of 1 (6 items) | RSS