Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
DOS/PDA/Other
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop drivers dvd email error excel firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem processor ram recovery router safe mode screen slow sound spyware tdlwsp.dll trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
batch file at shutdown not working

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
18-Oct-2009, 04:17 AM #1
batch file at shutdown not working
Dear all,
This is my first thread on group. please help me
I have a batch file as under:
@Echo Off
ClS
Echo REMOVE PEN DRIVE IF ANY!!
Pause
This has been added at group policy>shutdown part.
at the time of shutting down computer, it shows message that "running shutdown script", but I cant see that message and computer hang with message.
What is wrong i am doing?
Callum_Dawson's Avatar
Senior Member with 307 posts.
 
Join Date: Mar 2009
Location: Manchester, UK
Experience: Advanced
18-Oct-2009, 08:04 AM #2
It will probably be running as you get the "Windows is shutting down..." menu so you won't see it.
vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
18-Oct-2009, 08:18 AM #3
but then what should i do to have that message apeear on the screen. Moreover this shutting down message is running for half an hour..May be more, as I have manually shut down computer after half an hour
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,486 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
18-Oct-2009, 06:31 PM #4
Welcome to TSG!

A shutdown script runs under the System Account, so won't have a visible window, plus when the script is run, the system has already switched to the logon/logoff desktop which would hide it anyway.
A logoff script runs under the Current User's account, but also doesn't have a visible window. I'm guessing it is actually running in a System session (so it won't be visible) but with User permissions.
The pause statement makes it wait for the user to press a key, but since the window isn't visible, it will wait forever.

What you need to do is to call notepad to display a text file with the message.
Give this a try. It creates the text file, displays it for 5 seconds, then deletes it. The ping controls how long the message displays, the time is in milliseconds, so 5000=5 seconds.
If running Vista/Win7 you can use timeout 5 in place of the ping statement
You may want to run this as a logoff script rather than a shutdown script, so it will display if they just logoff instead of shutdown.
Code:
@Echo Off
>"%~dp0\Message.txt" Echo REMOVE PEN DRIVE IF ANY!!
Start Notepad.exe "%~dp0\Message.txt"
ping 1.0.0.0 -n 1 -w 5000
Del "%~dp0\Message.txt"
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?
vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
19-Oct-2009, 12:19 AM #5
This vb script is working. It shows the message window at the shutdown. Thanks for ur help.

Dim MyVar

MyVar = MsgBox ("Remove pen drive if any", 0, "Vipul's message")
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,486 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
19-Oct-2009, 01:28 AM #6
You're welcome, thanks for posting your solution.

If your issue has been resolved you (and ONLY you) can mark this thread Solved by using the Mark Solved button at the Top Left of this thread (above the first post)



Jerry
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?
Reply Bookmark and Share

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 10:56 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.