0

I have a bat script that if i run it on cmd it is working fine. However, if I right click and run as admin it broke. Has anyone seen this behavior?

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by k2k
0

How do you know it is broke and not running? have you tried adding pause statements to the bat file to force it to show the command line results. which version of windows??

0

it is win2008 ent sp2

the weird thing is that i did add a pause and nothing was wrong from the output.. no error nothing. see comment below

type %rptPath%emailHeader.eml > %rptPath%nbmail.eml

echo. >>%rptPath%nbmail.eml
echo. >>%rptPath%nbmail.eml

echo Report mailed on: %date% %time% >> %rptPath%nbmail.eml

for /f %%a in ('dir /B ^| findstr /R distlist_vault*') do type %%a >> %rptPath%nbmail.eml   ::::::::: this is the line that has problem

copy %rptPath%nbmail.eml C:\inetpub\mailroot\Pickup  ::this emails nbmail.eml out

move %rptPath%distlist_vault* %rptRepo%

cd %nbmailPath%

pause

running on cmd would grep info i need and >> to nbmail.eml and email it out with all content i need. running by right click "run as admin" would still email it out except for the line i commented having problem missing the info I need.

0

another update for those of you interested in this...

if you have a win2008 box you may try this.

do a simple script as follow (you need to create a hi.txt file with some content)

type hi.txt > output.txt

if you double clicked on the script it will run fine.
if you right click and run as admin, the script will be broken with the message saying "The system cannot find the file specified"

0

anyway, solved. use absolute path for everything not working.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.