Solved: Batch file to return filepaths

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Gudzy

Thread Starter
Joined
Jan 26, 2009
Messages
53
I'm trying to edit a text file on multiple computers in the domain using a batch file.

I've made a vbscript file which makes the required changes to the file if I give it the filepath but I am struggling to work out how to give it the filepath using a batch file. There will be multiple instances of the text file that requires changing on each PC, so I need to script which will find each file and then return it's filepath so I can call the other script with it:

The text files will all be in "My Documents" like this: %USERPROFILE%\My Documents\Phone\????\settings.txt where ???? will be 4 numbers and the settings.txt file will always be inside the ???? folder.

Could anyone give me some idea of how to return the filepath of the settings.txt file and how to pass it to another script.
 

foxidrive

Banned
Joined
Oct 20, 2012
Messages
793
This should launch the VBS script for each settings.txt one after the other. The VBS file has to access the command line to get the path\filename

Code:
@echo off
for /f "delims=" %%a in ('
dir /s /b /a-d "%USERPROFILE%\My Documents\Phone\settings.txt"
') do start "" /w cscript /nologo "script.vbs" "%%a"
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top