There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
DOS/Other
Tag Cloud
access acer asus bios bsod computer crash driver drivers error ethernet excel freeze gaming google gpu hard drive hardware hdmi internet laptop malware memory missing monitor motherboard network operating system printer problem ram registry router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/Other >
batch file at shutdown not working

Reply  
Thread Tools
vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
18-Oct-2009, 05: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 539 posts.
 
Join Date: Mar 2009
Location: United Kingdom
Experience: Advanced
18-Oct-2009, 09: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, 09: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 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
18-Oct-2009, 07: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 Expert - Consumer
Of course I know all the answers ; I just don't always match the answers to the right questions

vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
19-Oct-2009, 01: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 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
19-Oct-2009, 02: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 Expert - Consumer
Of course I know all the answers ; I just don't always match the answers to the right questions

Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:24 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.