Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Why Batch file doesn't work on certain comps  (Read 2159 times)

0 Members and 1 Guest are viewing this topic.

Debello

  • Guest
Why Batch file doesn't work on certain comps
« on: November 03, 2005, 01:56:59 PM »
There are a lot more of the following if statments...

if %username% EQU 121716 GOTO skip
if %username% EQU 121726 GOTO skip
if %username% EQU 121703 GOTO skip
cd c:\
shutdown /r /t 99 /c "If you are working at this workstation inform the lab monitor immediately"
:skip
exit


Can anyone explain why this batch would work properly on one computer and every other computer it is on locks up?

when i turn echo off I see that it gets passed all the IF statements and does the
c:\shutdown /r /t 99 /c "If you are working at this workstation inform the lab monitor immediately"
at the prompt but then the batch is stuck and can only be closed manually and no restart occurs.

the batch is running under winxp

Debello

  • Guest
Re: Why Batch file doesn't work on certain comps
« Reply #1 on: November 03, 2005, 01:59:23 PM »
if one of the "if" statements is true it runs properly and exits.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Why Batch file doesn't work on certain comps
« Reply #2 on: November 03, 2005, 02:06:57 PM »
Switches for shutdown are passed as -r -t -c, not with forward slashes. Also isn't shutdown in the c:\windows\system32 directory?

Just a small thought, but if the system actually carries out the shutdown, you really don't need to exit the command window.

8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

Debello

  • Guest
Re: Why Batch file doesn't work on certain comps
« Reply #3 on: November 03, 2005, 02:34:18 PM »
changing it to the system32 directory fixed it.

I guess one of the other people took out paths so programs couldn't be easily ran from the prompt.

but i've never had a problem with / switches

I use them in all my batches and they work fine for me.

almost all ? descriptions do give a - switch but i just use / since it's easier.

FreedomThief

  • Guest
Re: Why Batch file doesn't work on certain comps
« Reply #4 on: November 09, 2005, 01:05:58 PM »
i'm not sure what your system runs or not, but i know that with the systems that i use, you don't have to even go to the c:/windows/system32 directory, you can just use the command as it is, such as a batch file would be

@echo off
shutdown -t 99 -r -s -c "this is the comment"
end

or something like that....