cmd line run and background run difference

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

cmd line run and background run difference

#1 Post by goodywp » 20 Aug 2020 07:50

Hi all,

I had an experimental run between cmd line and background run. The cmd line run successfully. However, I found that the background run stopped at certain point not completed.
I tried using start /wait cmd /c call, and meanwhile put exit at the end of that batch file in this case, remoteDownloadGenerator.bat. During execution, this file opened another two cmd line windows. I attached this batch file here. You can see at the end of this file is GOTO:EOF

Code: Select all

start /wait cmd /c call "%Base_Scripts%\Scripts\remoteDownloadGenerator\remoteDownloadGenerator.bat" "%RDG_PACKAGE_SOURCE%" "" 
So my questions is that if I put exit after GOTO:EOF, it will not work, right?

here is the end of this remoteDownloadGenerator.bat

Code: Select all


GOTO:EOF
exit

What else I can do so that I can run this script to the end in background run...

tried change the last GOTO:EOF to GOTO end as below

Code: Select all

.............

GOTO:EOF

...............
GOTO:EOF

...............
GOTO end
:end
exit

the above change works in cmd line run but still not working in background run

Thanks
Attachments
remoteDownloadGenerator.7z
(8.11 KiB) Downloaded 400 times

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: cmd line run and background run difference

#2 Post by aGerman » 20 Aug 2020 12:15

What exactly does "background run" mean and how do you execute the script in this case?

Steffen

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: cmd line run and background run difference

#3 Post by goodywp » 20 Aug 2020 15:27

Hi Steffen,

I implemented in bamboo plan which shall run in bamboo server. I think that it could be like scheduled task to run in Windows. On Bamboo it called inline scripts...

I tested the script itself on bamboo server using cmd line it works. But when I run it from bamboo plan on browser it will not complete the task..

Thanks

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: cmd line run and background run difference

#4 Post by aGerman » 21 Aug 2020 07:30

OK, since I don't have any knowledge about this bamboo thing I can neither tell how it executes a command line nor how to solve your problem. Sorry.

Steffen

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: cmd line run and background run difference

#5 Post by goodywp » 21 Aug 2020 14:21

Thanks Steffen!

This Bamboo plan run can be literally treated same as Windows scheduled task background run...

So far observed,there are some difference of running in cmd line and background run, for both some Batch scripts or some PowerShell scripts behavior...

Thanks again....

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: cmd line run and background run difference

#6 Post by aGerman » 21 Aug 2020 15:58

In your code you rely on %cd% being the root for certain scripts and 3rd parties. One of the pitfalls when running scripts in a scheduled task is the assumption that %cd% is automatically the script directory (which is only the case if you correctly specified the "Start in" property). No idea whether or not such a property can be specified in your case. However, a CD /D "%~dp0" at the beginning of the script might be helpful. Still plain guessing though ...

Steffen

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: cmd line run and background run difference

#7 Post by goodywp » 09 Sep 2020 14:21

Thanks Steffen! good suggestion and helpful!

Post Reply