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

x
?
Solved

Windows XP run one program only

Posted on 2008-10-07
9
Medium Priority
?
1,661 Views
Last Modified: 2012-05-05
I need to run only one program on a Windows XP (32 bit) system.
If the user tries to exit the program the system must shut down.
i.e. No Presentation manager.

Is this possible ?
0
Comment
Question by:hansw77041
[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
  • 3
9 Comments
 

Expert Comment

by:ajwellsy
ID: 22666130
I have done this before.

I created a batch file that writes the tasklist to a text file using tasklist /v, and then the batch file searches for a particular task and if it does not exist I execute shutdown -r -t 15.  The batch file is executed via GP and runs 'hidden' and has a sleep time so that the computer boots, auto logs in and the program runs.  

If you can tie down the desktop (via GP) so users are unable to cancel the batch file running in the background and run only the single program you need to run.

This assumes you can use GP of course.


0
 
LVL 2

Accepted Solution

by:
simeonf earned 1000 total points
ID: 22666540
Hi hansw77041,

Have a look at the registry key HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell.

You can put an arbitrary executable in there, which will run at logon instead of the standard explorer shell.

This will solve the first part of your problem, the next part is how to shutdown when this program is closed - there may be more registry settings which make it easy to enforce this but I don't know of them.

You could implement a WMI event sink via vbscript to respond to a particular named process ending - see code sample below for making a temporary event consumer that checks each seconds and triggers a msgbox when the specified process ends. Run the script in the background as a part of the login script for example and you have a nice way to watch for and respond to your program ending.

This is called a temporary event consumer because it's only active while the vbscript is running (eg kill wscript.exe/cscript.exe and the consumer stops). You can also make them permanent but it's not trivial, I can point you in the right direction if you want to try this path too!

HTH!
Simeon
strComputer = "."
processToWatch = "iexplore.exe"
 
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMonitoredProcesses = objWMIService. _ 
ExecNotificationQuery("select * from __instancedeletionevent within 1 where TargetInstance isa 'Win32_Process'")
i = 0
Do While i = 0
  Set objLatestProcess = colMonitoredProcesses.NextEvent
  If ucase(objLatestProcess.TargetInstance.Name) = ucase(processToWatch) Then
    msgbox "Process " + processToWatch + " has terminated."
    'insert shutdown command here'
  End If
Loop

Open in new window

0
 

Author Comment

by:hansw77041
ID: 22670536
Hi ahwellsy,
One clarification please:  What is GP ?

I'll try these suggestions tomorrow.
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:hansw77041
ID: 22671106
Can't find   HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell.

HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ no Shell !

What am I missing ?

0
 
LVL 2

Expert Comment

by:simeonf
ID: 22674232
Ah I didn't realise, it may not exist by default, in which case the default of explorer.exe is chosen.

If it's not present you can just create it as a string value, and enter the full path to the executable you'd like to run at logon instead of explorer.exe.
0
 

Expert Comment

by:ajwellsy
ID: 22674917
Hi hansw77041,

Sorry GP is Group Policy.

If you are running Active Directory you can use Group Policy to tie down the desktop.

I know the solution I have posted is crude, but it is affective.  

I will try and dig out the code and post it.
0
 

Assisted Solution

by:ajwellsy
ajwellsy earned 1000 total points
ID: 22676000
Here is some code I use, this detects if a process (game) is running from a list in detect.txt, however it could easily be modified to see if a process does not exist.

Crude but effective :)
c:
cd \windows
 
:start
sleep 30
tasklist /V >c:\temp\tasklist.txt
Echo %NWUSERNAME% >c:\temp\detect.txt
Echo %COMPUTERNAME% >>c:\temp\detect.txt
time /t >>c:\temp\detect.txt
date /t >>c:\temp\detect.txt
findstr /G:c:\temp\games.txt c:\temp\tasklist.txt >>c:\temp\detect.txt
findstr /G:c:\temp\games.txt c:\temp\tasklist.txt >>c:\temp\detect.txt
findstr /G:c:\temp\games.txt c:\temp\tasklist.txt >>c:\temp\detect.txt
FOR /F "skip=5" %%1 IN (c:\temp\detect.txt) DO goto games
goto start
 
:games
FOR /F "skip=5" %%i IN (c:\temp\detect.txt) DO set game=%%i
shutdown -r -t 10
blat c:\temp\detect.txt -to admin@domain.com -f detector@domain.com -s "*** Aplication ***" -server mail.domain.com
 
:end
Echo why did I get here?

Open in new window

0
 

Author Comment

by:hansw77041
ID: 22726632
Thanks for the help.
I split point because both solutions worked and each one had good points the other did not have.

I hope this is acceptable.

0
 
LVL 2

Expert Comment

by:simeonf
ID: 22727026
No probs hansw, glad to be of assistance!
0

Featured Post

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

721 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