1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Batch file to return filepaths

Discussion in 'DOS/Other' started by Gudzy, Jan 8, 2013.

Thread Status:
Not open for further replies.
  1. Gudzy

    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.
     
  2. foxidrive

    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"
     
  3. Gudzy

    Gudzy Thread Starter

    Joined:
    Jan 26, 2009
    Messages:
    53
    Thanks foxidrive, that's working for me now
     
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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1084273

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice