[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 841
  • Last Modified:

Log off user when a specific application closes -- How To?

Have a Windows 2000 Professional workstation in a manufacturing environment.  It runs an application specific to some industrial equipment.  Want to set up the workstation launch this application automatically upon logon (this is easy), but also want to limit user activity on the computer.  The main thing we'd like to do is configure Windows to log off automatically when the application is exited.  Anyone have any suggestions for an easy / straightforward way to do this?
0
sunstoned
Asked:
sunstoned
1 Solution
 
JamesDSCommented:
sunstoned

You could have the logon run a batchfile that includes the following command:

rundll32.exe shell32.dll,SHExitWindowsEx 0

The idea is, the batchfile starts the app (with the START /WAIT command) and waits until it's finished, then runs the loggoff command.

The command used to be used on Windows 98 and ME, but might work for you.

Cheers

JamesDS
0
 
craylordCommented:
If you run scripts you could assign the script below to the username that logons. This script is with kixtart. If you don't use it, you could download (www.kixtart.org), extract it in c:\kix, then save the script below as "check.kix" in the c:\kix folder. At the user properties box (profile tab) enter this in the login script box:

c:\kix\kix32.exe "c:\kix\check.kix"


;----------------------------------------------------------
sleep 300 ;Pauses the script for 300 seconds, enough time to ensure the program is running
;color n/n ;uncomment this line to make the text black to hide from the user
:start
If checkforprocess(iexplore.exe)="false"
   logoff(1)
   sleep 5
      else
      ? "Explorer is open"
      ? "waiting for 5 minutes"
      sleep 5
endif
goto start

Function CheckForProcess($ProcessName)
      $CheckForProcess = "false"
      $processes = GetObject("winmgmts://" + @WKSTA).InstancesOf("win32_process")
      For Each $process in $processes
            If $process.Name = $ProcessName
                  $CheckForProcess = "True"
                  ;Exit
            EndIf
      Next            
EndFunction
0
 
craylordCommented:
I forgot! If the user forces the script to end via task manager it will log them off as well. You could also add a short cut to run this in the startup folder. This way it would run off of the network, in case they were smart enough to unplug the network cable before loggin on. :)

c:\kix\kix32.exe "c:\kix\check.kix"
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
craylordCommented:
Man i just keep forgetting stuff. Instead of the first line:
sleep 300 ;Pauses the script for 300 seconds, enough time to ensure the program is running
You could replace it with:

run "c:\your program folder\run.exe"
sleep 60

I know you stated you already got this part down, but this would make sure everything ran in the proper startup sequence.
0
 
craylordCommented:
crud again, there this is better

;--------------------
run c:\windows\notepad.exe
sleep 15
;color n/n ;uncomment this line to make the text black to hide from the user
:start
If checkforprocess(notepad.exe)="false"
   logoff(1)
   sleep 5
      else
      sleep 5
endif
goto start

Function CheckForProcess($ProcessName)
      $CheckForProcess = "false"
      $processes = GetObject("winmgmts://" + @WKSTA).InstancesOf("win32_process")
      
      For Each $process in $processes
            If $process.Name = $ProcessName
                  $CheckForProcess = "True"
                  ;Exit
            EndIf
      Next            

EndFunction
0
 
craylordCommented:
One last security measure, put a shortcut in c:\documents and settings\all users\start menu\programs\startup
that points to the c:\kix32.exe
Within the properties of the shortcut the target should be
c:\kix\kix32.exe "c:\kix\check.kix"

Reduce the rights of the user on the pc so that he cannot delete this shortcut. :)
0
 
sunstonedAuthor Commented:
geeze craylord... exhaustive answer.  will have to try this, but looks good.  i use kix on my domain controllers, so this makes sense.  thanks.  if anyone else has any easier answers, let me know, but this looks promising.
0
 
craylordCommented:
no prob, it's just another module i can plug into my bag of tricks. Have any useful scripts you'd care to exchange? Could create a question for points. Currently my domain script records user logins from user to pc, pc to user, hardware info (inc/serial#'s), software, support for automatic or user initiated incremental workstation user profile backups, automatic software installs/upgrades (office), sp2 and configuration of windows firewall, internet proxy settings. With checks to make sure their at the correct work site so they don't accidentally get an update from across the country.
0
 
sunstonedAuthor Commented:
not sure i have any scripts savvy enough to be worth your while... mine just perform basic drive letter mapping, printer installation, etc.  thanks for the offer though, is a neat idea.
0
 
Nirmal SharmaSolution ArchitectCommented:
>>>Have a Windows 2000 Professional workstation in a manufacturing environment.  It runs an application specific to some industrial equipment.  Want to set up the workstation launch this application automatically upon logon (this is easy),

If this is the particular requirement then change the following registry keys to your application:  -

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon

In Right Pane you will see one entry called "Shell=Explorer.exe". Edit Shell entry and put your application exe name here with path.

NOTE: - When user logs on to their machine the default shell of Windows (explorer.exe) is executed from the above registry key. If you put your application name here the application will be lunched immedietly after the user log in.

>>>but also want to limit user activity on the computer.  

The application will run under the security context of SYSTEM or Administrator account. So user has limited rights to perform any function.

>>>The main thing we'd like to do is configure Windows to log off automatically when the application is exited.  Anyone have any suggestions for an easy / straightforward way to do this?

That's easy. Put a log off script. When user exists from application this will put them back to Log on screen.

Let me know.

Thanks
SystmProg
0
 
sunstonedAuthor Commented:
Craylord, I awarded you the points.  Ended up using a different solution altogether, but your efforts and thouroughness deserve the full award.  Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now