954,315 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

bat script run on cmd only???

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?

k2k
Posting Whiz
352 posts since Nov 2007
Reputation Points: 15
Solved Threads: 1
 

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

rch1231
Posting Shark
959 posts since Sep 2009
Reputation Points: 119
Solved Threads: 142
 

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.

k2k
Posting Whiz
352 posts since Nov 2007
Reputation Points: 15
Solved Threads: 1
 

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"

k2k
Posting Whiz
352 posts since Nov 2007
Reputation Points: 15
Solved Threads: 1
 

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

k2k
Posting Whiz
352 posts since Nov 2007
Reputation Points: 15
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You