# \[Shared Library\] Unable to run a batch commmand from a shared library

**URL:** <https://community.jenkins.io/t/shared-library-unable-to-run-a-batch-commmand-from-a-shared-library/5465>\
**Category:** Using Jenkins\
**Created:** [January 25, 2023, 4:06am UTC](https://community.jenkins.io/t/shared-library-unable-to-run-a-batch-commmand-from-a-shared-library/5465 "2023-01-25T04:06:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kikmon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/kikmon/32/2837_2.png) [@kikmon](https://community.jenkins.io/u/kikmon)\
**Post date:** [January 25, 2023, 4:06am UTC](https://community.jenkins.io/t/shared-library-unable-to-run-a-batch-commmand-from-a-shared-library/5465/1 "2023-01-25T04:06:34Z")

</div>

Hi

I’m in the process of moving common code from my jenkinsfile into a shared library.  
Everything went well until I tried to move code that uses ‘bat’ steps.  
I understand you are not supposed to call Jenkins steps from shared libraries (doable if you insist well), so I tried using the ProcessBuilder class to run cmd.  
But whatever I do, I always end up with a ‘No such file or directory’. Such as ‘Cannot run program “C:\Windows\System32\cmd.exe”: error=2, No such file or directory’ (and yes, the function is called in a windows agent)

Am I doing the right thing here ?  
Is Jenkins preventing me from accessing programs on the node on purpose ?

Thanks

---

<div class="post-metadata">

**Author:** ![halkeye](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/halkeye/32/8_2.png) [@halkeye](https://community.jenkins.io/u/halkeye)\
**Post date:** [January 25, 2023, 6:02am UTC](https://community.jenkins.io/t/shared-library-unable-to-run-a-batch-commmand-from-a-shared-library/5465/2 "2023-01-25T06:02:44Z")

</div>

Process builder, being a native java class doesn’t know anything about controller to agent  
Would recommend you use the pipeline bat step

---

<div class="post-metadata">

**Author:** ![kikmon](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/kikmon/32/2837_2.png) [@kikmon](https://community.jenkins.io/u/kikmon)\
**Post date:** [January 26, 2023, 2:49am UTC](https://community.jenkins.io/t/shared-library-unable-to-run-a-batch-commmand-from-a-shared-library/5465/3 "2023-01-26T02:49:42Z")

</div>

Thanks for the answer

Jenkins steps are not available by default.  
Does it mean I need to add the script object to my function signature so I can call script.steps. functions ?
