Getting Data In

scripted input batch script cant access files in same dir

rlourenco
Engager

Hi,

My Windows batch script executes a bin file and uses a text file to hold the state of the last execution, all the necessary files are in the same directory. When I test it from the command line it works fine, but when the script handler runs it it can't read any of the files.
I placed my files in "C:\Program Files\Splunk\bin\scripts\customdir".
Can anyone help me out?

Thanks for any help,

Rui

Tags (1)
0 Karma
1 Solution

Ayn
Legend

The scripts don't run with the script's directory as the working directory. I don't remember which directory is used on Windows (maybe %TEMP%?) but running cd in your script and check what it outputs should give you the answer you need to that question.

View solution in original post

Ayn
Legend

The scripts don't run with the script's directory as the working directory. I don't remember which directory is used on Windows (maybe %TEMP%?) but running cd in your script and check what it outputs should give you the answer you need to that question.

Ayn
Legend

Awesome! Could you please mark my answer as accepted? Thanks!

0 Karma

rlourenco
Engager

Thanks! I didn't think of doing that!

Running "@echo Current dir %CD%" showed it was running under C:\WINDOWS\system32, so then I added a CD to the beginning of my script to change to the working directory.

Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...