Solved

Windows XP run one program only

Posted on 2008-10-07
9
1,648 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
  • 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
 

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Can you find a fax from a vendor you saved a decade ago in seconds? Have you ever cursed your PC under your breath during an audit because you couldn’t find the requested statement or driver history?  If you answered no to the first question or yes …
Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now