Computing.Net > Forums > Windows XP > Batch File HELP!!!!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File HELP!!!!

Reply to Message Icon

Name: badbloodyeyez
Date: October 10, 2008 at 11:13:39 Pacific
OS: XP pro
CPU/Ram: 1GB
Product: Novatech
Comment:

Hi,
I would like to know if I could close a process automatically using a batch file I can close a program using a batch file but I want to close a program as soon as it starts automatically. for example If I open the notepad the batch file should automatically detect it and close it rather then me clicking on the batch file so basically the batch file should start and monitor the program automatically and as soon as the program is run it should close it. Hope Im clear. Waiting for reply thanx



Sponsored Link
Ads by Google

Response Number 1
Name: wanderer
Date: October 10, 2008 at 11:43:42 Pacific
Reply:

can't do that with batch files. you can do it with programming.


0

Response Number 2
Name: toast (by NoIdea)
Date: October 10, 2008 at 12:05:30 Pacific
Reply:

This is how to do it with batch

@echo off
cls
:loop
@ping -n 01 127.0.0.1>nul
tasklist 2>nul | find /i "????????.exe" >nul || goto :loop
taskkill /f /t /im ??????.exe
exit


0

Response Number 3
Name: badbloodyeyez
Date: October 11, 2008 at 09:21:31 Pacific
Reply:

oh yes it works perfect thanx! and is it possible to autorun this file rather than me opening it


0

Response Number 4
Name: toast (by NoIdea)
Date: October 11, 2008 at 14:48:27 Pacific
Reply:

Need some more information about how you want to do this.
Glad it works. Sorry about the delay been a bit busy today.


0

Response Number 5
Name: badbloodyeyez
Date: October 12, 2008 at 08:57:28 Pacific
Reply:

ok what I want to do is that the batch file should run automatically upon log on I know how to do this I figured it out now I want to hold the log off and shutdown process automatically so it is the same thing as before but this time it will look for the log off file and cancel it I tried it but it doesnt work! The following is the same code which you gave me but with the file which switch the user
@echo off
cls
:loop
@ping -n 01 127.0.0.1>nul
tasklist 2>nul | find /i "tsdiscon.exe" >nul || goto :loop
taskkill /f /t /im tsdiscon.exe
exit
the tsdiscon.exe file is the file which switch user when you press switch user i want to find this file and if it is running stop it from being executed is this possible?? plz help on this I wrote another file which when run will pause the switch user process until the user hits an key the code is
cd\
cd c:
cd WINDOWS
cd system32
pause
tsdiscon.exe
so to summerise I want to hold the log off/ shutdown/ switch user operation when the user hits the log off/ shutdown or switch user button thanx


0

Related Posts

See More



Response Number 6
Name: toast (by NoIdea)
Date: October 13, 2008 at 10:03:24 Pacific
Reply:

I am a little confused. Why don't you just disable Fast User Switching as a service?
Does tsdiscon.exe run within svchost?
I believe it does but you may know?
Open a cmd /k then enter
tasklist /svc /fi "imagename eq svchost.exe"
if you see something like FastUserBlahblah then you can put the results into a text file and then look in there to stop it. But I am still confused as to why you need to go down this route instead of stopping the service.
Sorry if I am being dim.


0

Response Number 7
Name: badbloodyeyez
Date: October 15, 2008 at 03:46:12 Pacific
Reply:

Sorry for the late reply no I dont want to stop it I just want to hold it as you know that when you shutdown and if you want to cancel it then you could type "shutdown -a" in the run box and it will cancel it also you can write this as an batch file the reason I want to know this is because I am doing a project in which I want this software the software will hold the log off/ shutdown operation and will do something else then continue the log off operation. Is it posible to do it with batch file? or I have to use VB to do this!


0

Response Number 8
Name: toast (by NoIdea)
Date: October 15, 2008 at 04:25:10 Pacific
Reply:

I am still not sure if we are on the same page.
Is this what you want?

Title badbloodyeyez batch script
@echo off
cls
:Loop
echo.
echo YOU NOW HAVE 4 CHOICES:-
echo.
echo TO LOG OFF TYPE L
echo.
echo TO SHUTDOWN COMPUTER TYPE S
echo.
echo TO RESTART COMPUTER TYPE R
echo.
echo TO USE COMPUTER TYPE C
echo.
set /p inp= TYPE THE LETTER AND PRESS ENTER: -^>
if %inp%==l goto loff
if %inp%==s goto sdown
if %inp%==r goto sdownr
if %inp%==c goto exit
cls
GOTO :Loop
:loff
cls
shutdown -l -t 00
GOTO :exit
:sdown
cls
shutdown -s -f -t 05 -c "CATCH YOU LATER"
GOTO :exit
:sdownr
cls
shutdown -r -f -t 05 -c "SEE YOU IN A MINUTE"
GOTO :exit
:exit


0

Response Number 9
Name: badbloodyeyez
Date: October 15, 2008 at 09:54:09 Pacific
Reply:

yes very nice file thanks for your reply and code and is it possible to run this file automatically when the user press log off/ shutdown or restart I mean the user will click on start then log off or shutdown and then this file will run automatically is it possible??? and thanx for the code I really appriciate your help I really do thanx


0

Response Number 10
Name: toast (by NoIdea)
Date: October 15, 2008 at 13:15:35 Pacific
Reply:

If you put the batch file in say windows then make a shortcut to it you can choose an icon, size etc. You have to edit the properties of the shortcut You can make it look like shutdown. then using either group policy editor or the registry you can remove log off or shutdown from start menu.


0

Response Number 11
Name: badbloodyeyez
Date: October 17, 2008 at 12:51:24 Pacific
Reply:

I tried running my file on log off but this program does not work niether does it log off the way I done it is as follows
in the run type in gpedit.msc
then user configuration and then windows settings and then scripts
but it does not work!!!


0

Response Number 12
Name: toast (by NoIdea)
Date: October 17, 2008 at 15:45:54 Pacific
Reply:

What does not work? You need to be more precise with what is needed and happening.
The batch is not run as a shutdown script it is the shutdown, log off, restart.

These are the registry enteries to remove log off and shutdown. Do you know how to make a registry file. I hope so. Copy to notepad. Save as ?????.reg. Double click to merge into registry

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"StartMenuLogOff"=dword:00000001
"NoClose"=dword:00000001

Now make your shortcut to the batch file..... and now this is the part you need to tell me what you precisely need to do or wish to accomplish. OK as an idea.

Try this

Title Internet Explorer
@echo off
cls
color 1A
cls
echo.
echo.
echo Don't worry Internet Explorer is starting
start "" /wait /abovenormal "C:\Program Files\Internet Explorer\iexplore.exe" http://www.google.co.uk/
cls
:Loop
echo.
echo YOU NOW HAVE 4 CHOICES:-
echo.
echo TO HIBERNATE COMPUTER TYPE L
echo.
echo TO SHUTDOWN COMPUTER TYPE S
echo.
echo TO RESTART COMPUTER TYPE R
echo.
echo TO USE COMPUTER TYPE C
echo.
set /p inp= TYPE THE LETTER AND PRESS ENTER: -^>
for %%a in (l s r c) do if "%%a"=="%inp%" goto :%inp%
cls
goto :LOOP
:l
cls
shutdown -l -t 00
GOTO exit
:s
cls
shutdown -s -f -t 05 -c "CATCH YOU LATER"
GOTO exit
:r
cls
shutdown -r -f -t 05 -c "SEE YOU IN A MINUTE"
GOTO exit
cls
:c
exit


0

Response Number 13
Name: badbloodyeyez
Date: October 18, 2008 at 10:47:53 Pacific
Reply:

I am sorry if I'm being so noisy. Ok let me tell you wat I want to do ok If a user logs off I want to hold or cancel log off operation just like if the user wants to open notepad and we closed it so basically I dont want the user to log off or shutdown the computer!!!! but if he wants to log off/ shutdown he has to select a option just like in the code you gave me. So if the user press 'Start' and then 'log off' rather than the windows option comes which lets the user to log off or switch user the code you gave me will start


0

Response Number 14
Name: toast (by NoIdea)
Date: October 18, 2008 at 15:18:21 Pacific
Reply:

So you have your answers.
Use the registry keys to remove shutdown and logg off put a shortcut to the batch file in it's place

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"StartMenuLogOff"=dword:00000001
"NoClose"=dword:00000001


0

Response Number 15
Name: badbloodyeyez
Date: October 19, 2008 at 04:02:35 Pacific
Reply:

Thank you very much for your help I really appreciate it!


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Batch File HELP!!!!

Batch File Help www.computing.net/answers/windows-xp/batch-file-help/164222.html

Batch file help needed... www.computing.net/answers/windows-xp/batch-file-help-needed/163063.html

Dos Batch File HELP! www.computing.net/answers/windows-xp/dos-batch-file-help/163943.html