Check wether a script has been started through CALL or START

Various / HOME BUILT
May 24, 2017 at 22:44:46
Specs: Windows 10 Pro x64, Intel i7 6700k, 32GB 3200MHz DDR4 RAM
I need to add some functionality to one of my scripts where it determines whether it has been called with a CALL command or if it's been started through START or something similar to that. Is there a way to do this?

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)


See More: Check wether a script has been started through CALL or START

Reply ↓  Report •

#1
May 25, 2017 at 09:15:08
Nothing in batch will tell you. If you need special handling based on if the user starts it or another script does, the easiest thing to do would be to use arguments. By passing an argument when calling your script from another script, you can just check for the existence of %1. If it's there, you assume your script was called from another. If not, you assume the user started it (from an icon?).

How To Ask Questions The Smart Way


Reply ↓  Report •

#2
May 25, 2017 at 09:41:43
Thing is I want to add some functionality if it's being included to the same environment as a "main" file, having access to the same variables, etc.

I mean start, as in just entering the script name in cmd and pressing enter, or starting it using the START command, so checking for %1 wouldn't work

EDIT:
Just realized %0 when the script is called is whatever file name or path was used to call it, while when just run it's the full path.

Probably not the best solution but it could work

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)

message edited by RainBawZ


Reply ↓  Report •
Related Solutions


Ask Question