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?

Recommended Answers

All 4 Replies

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??

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.

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"

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.