Solved

Windows XP run one program only

Posted on 2008-10-07
9
1,653 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Looking to exFAT Driver for Win XP 11 9,997
Incredibly nasty malware/adware 15 71
Event ID: 5719 / Source: NETLOGON 9 127
Exchange & AD management console 2 101
There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like 192.168.xxx.1, I've seen routers with default values of: 192.168.0.1, 192.168.1.1, 192.168.11.1, …
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

776 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