Solved

Windows XP run one program only

Posted on 2008-10-07
9
1,656 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 250 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 250 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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