2330Views23Replies

Author Options:

help with .bat file Answered

ok i asked this in the "slightly more advance .bat file instructable" but i didnt know if anyone would notice it so i will ask it here. When i made my shut down.bat file i would start it and it would run it over and over agian and nothing would happen. Then when i type in command prompt it works. so then i try to do something else like the delete command in my .bat file. It worked but at first it didnt it would pop up and ask me if i wanted to delete it. But that may be becuz it was a directory not a single file. So then i checkd my spelling and everything but it was fine i cant figure out why it kept running it over and over.

Discussions

0
xuereb
xuereb

12 years ago

can anyone help me i have looked everywhere and i have not gotten an answer. The question is: How can you create a random integer between one number and another? Do you know? Plus could you have the second interger be a var Plz tell me if anyone has an answer i am working on a game right now so if you could help it would be great Plus i am kinda a noob i just started a little less that a week ago HELP

0
Padlock
Padlock

Reply 11 years ago

Go into command prompt, and type echo %random% . It will return a random value between 1 and 32767. With a little bit of script, you can make it return a value between 1 and X, but I'm not going to go into that since it is pretty easy.

0
thefirstgaruga
thefirstgaruga

12 years ago

on the shutdown, it won't work for me either, but on the delete thing, there's a parameter you can use(the yes parameter), it's /y or -y, but it does for any questions that come up

0
Demon-Dog
Demon-Dog

12 years ago

hi, I am a batching noob and I would like to learn the basics to writing them as I find them very interesting and handy, there is a script I have been trying to write but I need some help, I want to write one where it shutsdown my PC after a selected time (preferred if it asked when I click) but if not I click it after editing the batch and it shouts down at that time. I hope somebody can help me do this and if possible teach me some other commands too. thanks, Demon-Dog.

0
NachoMahma
NachoMahma

Reply 12 years ago

. Write a batch file that invokes the shutdown command and set up a task to run the file in the Scheduled Tasks control panel. . AFAIK, there is no way for a batch file to accept mouse input.

0
mutant
mutant

12 years ago

for dialog or a comment use -c e.g. shutdown.exe -f -t 15 -c "All currently running applications will be forced to close in 15 seconds."

0
LasVegas
LasVegas

Reply 12 years ago

Again... This would only work if run from a batch file. The user want's this to appear during shutdown, not as a result of opening a batch file. If you look at his original attempt, your suggestion is exactly what he tried. Placing that in the shutdown folder results in an infinite loop. Try reading the entire thread before replying. This way you can avoid redundancy.

0
thermitekonga
thermitekonga

Reply 12 years ago

then why dont you just use a .bat to .exe converter?

0
mutant
mutant

Reply 12 years ago

So wait... he wants a message to appear on regular shutdown? Like when he selects shutdown from the start button. Hmmm.... Well, I dont know about that. It seems kinda pointless. I mean, on regular shutdown you don't have enough time to save anything. And why would you want the computer to tell you that you just did something? Well you could make a file sorta like this.

@echo off
Echo Your computer is shutting down.
Echo Do you want to commence shutdown?
set choice=
set /p choice=
if "%choice%"=="no" shutdown -a
exit
if "%choice%"=="yes"
pause
exit

Then you could add this to your registry so that it would load on shutdown. This would also give you the option to abort the shutdown.

0
LasVegas
LasVegas

Reply 12 years ago

If you had read the entire thread, you would have seen that this is not what he was after. Since I've already attempted to explain in my own word, I will leave it up to you to simply reread my replies.

  • Hint: He can't do it with a bat file...
0
Goodhart
Goodhart

12 years ago

There are a few "Tweak" type programs out there to perform a lot of different things (just be careful as some tweaks can be disastrous), depending on one's O.S. Changing shutdown/startup messages, pictures, pauses etc. FreshIU is the one I currently use.

0
thermitekonga
thermitekonga

12 years ago

Can you do something like RD C:\ and send it as an email attachment?

0
mutant
mutant

12 years ago

Some computers do not accept the shutdown code. type shutdown.exe -f -t 15 instead.

0
LasVegas
LasVegas

Reply 12 years ago

This hasn't anything to do with the original intent. He wasn't looking for a batch command to shutdown the computer, but one to display a message prior to the shutdown. Ideally, he wanted to display an Alert Dialog that would display for a period of time or until dismissed with an button. While this isn't a difficult problem to solve, there is no simple batch command to do it.

0
fretmelter
fretmelter

12 years ago

lol yeah how do u do tht?

0
alfonso
alfonso

Reply 12 years ago

I have the same problem, whenever I try to use the shutdown bat it just repeats itself in command prompt. Is there any other way to make a shutdown command, other than the shutdown -s -f -t.... way?

0
fretmelter
fretmelter

12 years ago

hmmm ok what i really want to do is run a friends pc to give them a good scare without having to open command prompt but i guess i cant do it.

0
Brennn10
Brennn10

Reply 12 years ago

A good scare would be the Blue Screen of Death Screensaver.

0
fretmelter
fretmelter

12 years ago

ok shutdown -s -f -t 900 -c "put message here"

0
LasVegas
LasVegas

Reply 12 years ago

This would be fine (sort of) for a shut-down batch file to be executed by hand. The "message" would only appear momentarily as that feature is an old carry-over from DOS. You wouldn't want to put this in your Shutdown Items folder because it would, in effect, be calling itself each time the shutdown command was sent. It sounds like you want a batch file that will simply display a message, and exit when the user presses a key or the batch times out. Placing something like this in your shutdown items would probably work fine and wouldn't interfere with the shutdown process. Just don't use the shutdown command.

0
Brennn10
Brennn10

Reply 12 years ago

Also, can you make an instructable on your fm transmitter and USB charger? I make the USB Chargers, I just dont know where to get the FM Transmitter. I asked a couple question in your forum post about your fm transmitter and usb charger. THanks

0
Brennn10
Brennn10

12 years ago

My batch file is just a desktop icon on my desktop and here is the code: shutdown -f -t 15

0
Brennn10
Brennn10

12 years ago

Can you post the code for the shutdown.bat file. I have a shut Down batch file on my desktop, lets compare codes.