Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Logoff VB Script for Citrix Windows Server 2003

Posted on 2006-07-06
6
Medium Priority
?
471 Views
Last Modified: 2010-08-05
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.FileSystemObject")

strScriptPath = objFSO.GetParentFolderName(WScript.ScriptFullName)

If objFSO.FileExists(strScriptPath & "\Legal.txt") Then
      Set objLegalFile = objFSO.OpenTextFile(strScriptPath & "\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(strScriptPath & "\MOTD.txt") Then
                  Set objMOTDFile = objFSO.OpenTextFile(strScriptPath & "\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("winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}//./root/cimv2").ExecQuery( _
                   "Select * from Win32_OperatingSystem where Primary=true")
        for each OpSys in OpSysSet
          OpSys.Win32Shutdown(vbLogoff + vbForce)
        Next

End Sub
'================================================================

Thanks
0
Comment
Question by:sterlingdev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 9

Accepted Solution

by:
justchat_1 earned 2000 total points
ID: 17053233
Theres a shortcut you can try...im not familiar with that server but if you run "shutdown -l" on the server does it log off?
0
 

Author Comment

by:sterlingdev
ID: 17128548
I would like to fix the VB script really
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17132791
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)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sterlingdev
ID: 17142277
But then the users would need access to shutdown.exe right and that would be a bit of a security issue!
0
 

Author Comment

by:sterlingdev
ID: 17142279
Is there any other way?
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17143287
All users have access to shutdown.exe (unless explicitly prevented)...its a dos commend-just like net functionality
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question