sterlingdev
asked on
Logoff VB Script for Citrix Windows Server 2003
Hi,
I have a logon script which displays a Legal notice when users logon to Citrix. Part of this asks the user to agree/disagree and if they disagree it should log them off, but this doesn't work on the Citrix server, however does on XP clients. Please can anyone help.
The script I have is as follows:
'========================= ========== ========== ========== ==========
Option Explicit
Dim numQuestion
Dim objFSO, objLegalFile, objMOTDFile
Dim strScriptPath, strLegalText, strMOTDText
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
strScriptPath = objFSO.GetParentFolderName (WScript.S criptFullN ame)
If objFSO.FileExists(strScrip tPath & "\Legal.txt") Then
Set objLegalFile = objFSO.OpenTextFile(strScr iptPath & "\Legal.txt", 1)
strLegalText = objLegalFile.ReadAll
numQuestion = msgbox(strLegalText, vbYesNo + vbExclamation + vbDefaultButton2 + vbSystemModal, "Company Name")
If numQuestion = vbNo Then
Logoff()
WScript.Quit
Else
If objFSO.FileExists(strScrip tPath & "\MOTD.txt") Then
Set objMOTDFile = objFSO.OpenTextFile(strScr iptPath & "\MOTD.txt", 1)
strMOTDText = objMOTDFile.ReadAll
MsgBox strMOTDText, vbOKOnly + vbInformation + vbSystemModal, "Company Name"
End If
WScript.Quit
End If
Else
MsgBox "Legal notice not found. Unable to login. Please contact IT Support!", vbOkOnly + vbCritical + vbSystemModal, "Company Name"
Logoff()
End If
' This sub will logoff the current user, forcing any current apps to close.
Sub Logoff
' Win32Shutdown Method Constants
CONST vbLogoff = 0
CONST vbShutdown = 1
CONST vbReboot = 2
CONST vbPowerOff = 8
CONST vbForce = 4
Dim OpSysSet, OpSys
Set OpSysSet=GetObject("winmgm ts:{impers onationLev el=imperso nate,(Debu g,Shutdown )}//./root /cimv2").E xecQuery( _
"Select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.Win32Shutdown(vbLogo ff + vbForce)
Next
End Sub
'========================= ========== ========== ========== =========
Thanks
I have a logon script which displays a Legal notice when users logon to Citrix. Part of this asks the user to agree/disagree and if they disagree it should log them off, but this doesn't work on the Citrix server, however does on XP clients. Please can anyone help.
The script I have is as follows:
'=========================
Option Explicit
Dim numQuestion
Dim objFSO, objLegalFile, objMOTDFile
Dim strScriptPath, strLegalText, strMOTDText
Set objFSO = CreateObject("Scripting.Fi
strScriptPath = objFSO.GetParentFolderName
If objFSO.FileExists(strScrip
Set objLegalFile = objFSO.OpenTextFile(strScr
strLegalText = objLegalFile.ReadAll
numQuestion = msgbox(strLegalText, vbYesNo + vbExclamation + vbDefaultButton2 + vbSystemModal, "Company Name")
If numQuestion = vbNo Then
Logoff()
WScript.Quit
Else
If objFSO.FileExists(strScrip
Set objMOTDFile = objFSO.OpenTextFile(strScr
strMOTDText = objMOTDFile.ReadAll
MsgBox strMOTDText, vbOKOnly + vbInformation + vbSystemModal, "Company Name"
End If
WScript.Quit
End If
Else
MsgBox "Legal notice not found. Unable to login. Please contact IT Support!", vbOkOnly + vbCritical + vbSystemModal, "Company Name"
Logoff()
End If
' This sub will logoff the current user, forcing any current apps to close.
Sub Logoff
' Win32Shutdown Method Constants
CONST vbLogoff = 0
CONST vbShutdown = 1
CONST vbReboot = 2
CONST vbPowerOff = 8
CONST vbForce = 4
Dim OpSysSet, OpSys
Set OpSysSet=GetObject("winmgm
"Select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.Win32Shutdown(vbLogo
Next
End Sub
'=========================
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try what I posted, if it works I can post code to do the same thing in a vb script(its alot simplier then alot of api calls)
ASKER
But then the users would need access to shutdown.exe right and that would be a bit of a security issue!
ASKER
Is there any other way?
All users have access to shutdown.exe (unless explicitly prevented)...its a dos commend-just like net functionality
ASKER