Link to home
Start Free TrialLog in
Avatar of DUB_IT
DUB_IT

asked on

Running .Bat and .cmd files from network shares

Dear All,

I have a problem whic I'm sure should be easy to clear up. I have written a very simple batch file to launch a program at login. When I test the batch file locally on the machine it runs perfect, runs once, does what it is supposed to do and finishes, simple... so I thought. I then copied the batch file to a network share to make it available to all users. When I run the batch file from a network share it just keeps looping. The dos box opens as it should and the command just keeps looping, never stopping. The command being issued just updates the schedule on a poweroff program we use to shutdown all client machines every evening. Checkout http://users.telenet.be/jbosman/poweroff/poweroff.htm

Has anyone ever seen this happen before with a batch file?? Any help would be greatly appreciated.

Regards,

Kevin
poweroff -warn -warntime 180 -msg "WORKING NOW" -playsound -soundfile "c:\windows\media\ringin.wav" -force -scheduled -time 10:08 -days m,t,w,th,f -save_svc_set

Open in new window

Avatar of theras2000
theras2000
Flag of United States of America image

I know that batch file commands sometimes have trouble running from a UNC share path.  In fact I think they're officially nto supposed to, but sometimes they do.
Perhaps if you just change to the c: prompt in the 1st line of the batch file.  I'm going to go test and confirm this for you now.
ASKER CERTIFIED SOLUTION
Avatar of theras2000
theras2000
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try to run it with START

start "poweroff -warn -warntime 180 -msg "WORKING NOW" -playsound -soundfile "c:\windows\media\ringin.wav" -force -scheduled -time 10:08 -days m,t,w,th,f -save_svc_set"

Open in new window

Now if that is true for you, then you should be able to just modify your command to this:
\\pcname\share\poweroff -warn -warntime 180 -msg "WORKING NOW" -playsound -soundfile "c:\windows\media\ringin.wav" -force -scheduled -time 10:08 -days m,t,w,th,f -save_svc_set 

Open in new window

Avatar of Steve Knight
Is your batch file called poweroff.cmd or poweroff.bat.... sounds like it is getting to the point when it runs poweroff.exe and you are re-running your batch file?!

Steve
i.e. call your batch file something else if so...
Avatar of DUB_IT
DUB_IT

ASKER

Hi Guys, thanks for all the suggestions, I'm going to look at it now and see what I can find
Avatar of DUB_IT

ASKER

Oh I called it poweroff.cmd AND poweroff.bat to see if either or the extensions made a difference and it did not. I am going to try and rename it to something like test.cmd and also try the option of changing to the c:\ before it runs
Avatar of DUB_IT

ASKER

Hi Guys, thanks for your input. I think I have it sorted. I need to cd to the directory poweroff.exe is in before the command initiates. This worked straight away. Thaks for your thoughts, they steered me in the right direction.

Very much appreciated.

Regards,

Kevin