# How to trigger script using .bat from 'current directory' provided by input file

**URL:** https://forums.powershell.org/t/how-to-trigger-script-using-bat-from-current-directory-provided-by-input-file/4715
**Category:** PowerShell Help
**Created:** [August 18, 2015, 4:41pm UTC](https://forums.powershell.org/t/how-to-trigger-script-using-bat-from-current-directory-provided-by-input-file/4715 "2015-08-18T16:41:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sachin-ghagare](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sachin-ghagare](https://forums.powershell.org/u/sachin-ghagare)
#### Post date: [August 18, 2015, 4:41pm UTC](https://forums.powershell.org/t/how-to-trigger-script-using-bat-from-current-directory-provided-by-input-file/4715/1 "2015-08-18T16:41:46Z")

</div>

Hi All,

I’m not able to execute PowerShell script successfully using .bat file provided by input file whereas it succeeds from PowerShell console/ISE

Error: get-content : Cannot find path ‘C:\Windows\system32\BulletinIDList.txt’ because it does not exist.

it seems script executes in ''C:\Windows\system32' context…how do I force script to look for input file in ‘current directory’? please advise..!

## Below is script contents to read input from txt file,

$currentFolder = $PWD.Path  
$GetBulletins = Join-Path $currentFolder “BulletinIDList.txt”  
$BulletinIDList = get-content $GetBulletins

* * *

Thanks

---

<div class="post-metadata">

### Author: ![robbiepc30](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@robbiepc30](https://forums.powershell.org/u/robbiepc30)
#### Post date: [August 18, 2015, 6:15pm UTC](https://forums.powershell.org/t/how-to-trigger-script-using-bat-from-current-directory-provided-by-input-file/4715/2 "2015-08-18T18:15:35Z")

</div>

You need to use the $MyInvocation.MyCommand.Path to pull the correct directory that your script is running in. When you launch a PowerShell.exe by default it goes to the Path C:\Windows\system32. Your script is pulling that path when your are doing $PWD.Path  
Replace the following to pull the current location of the script.

$currentFolder = Split-Path -Parent $MyInvocation.MyCommand.Path

---

<div class="post-metadata">

### Author: ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)
#### Post date: [May 16, 2024, 8:44pm UTC](https://forums.powershell.org/t/how-to-trigger-script-using-bat-from-current-directory-provided-by-input-file/4715/3 "2024-05-16T20:44:55Z")

</div>


