Windows 10: batch file is not working

Discus and support batch file is not working in Windows 10 Network and Sharing to solve the problem; Hi world,I need to get an absolute path value like this but it's not working well.batch file:==================================for /F "tokens=1" %%i in... Discussion in 'Windows 10 Network and Sharing' started by Junho_Lee, Oct 3, 2024.

  1. Junho_Lee Win User

    batch file is not working


    Hi world,I need to get an absolute path value like this but it's not working well.batch file:==================================for /F "tokens=1" %%i in 'PowerShell -Command "& {Get-ChildItem %USERPROFILE%\Desktop\privacy\*.xlsx select -exp Name -last 1}"' do set FNAME=%%i ==================================result:==================================set FNAME Environment variable FNAME not defined --> ERROR==================================So I did like this on cmd, it works.cmd:==================================for /F "tokens=1" %i in 'PowerShell -Command "& {Get-Chil

    :)
     
    Junho_Lee, Oct 3, 2024
    #1
  2. oily_17 Win User

    Batch Files Knowledge Base

    Don't use batch files very much but one I find useful is for creating a list of files in a directory.
    Just copy the text below into Notepad and save as Filelist.bat

    dir /a /-p /o:gen >filelist.txt

    When you run it from a folder it will create a Filelist.txt file,in the same folder, that lists all the files in that folder.Useful when you are too lazy to type all the files out yourself.
     
    oily_17, Oct 3, 2024
    #2
  3. Batch Files Knowledge Base

    Very nice and usefull thanks for contributing.
     
    AphexDreamer, Oct 3, 2024
    #3
  4. batch file is not working

    Batch file not working

    I'm afraid your batch file suffers from numerous problems. Here is a list of them:

    • I do not understand what the set YYY... is supposed to do.
    • There is no need to create variables for date, time and random. You can use them directly in your code.
    • In some countries, the %time% variable includes colons batch file is not working :)). They cannot be used in file names. Same for the %date% variable if it includes forward slashes (/).
    • In batch files you MUST fully qualify all file names.
    • "Goto" statements should be avoided as much as possible. Use loops instead (see below).
    • In your copy command you MUST put double quotes around file/folder names that have embedded spaces.

    Here is a cleaned up version of your batch file:

    Code:
    @echo offset YYYYMMDD=%4%%DATE:~4,2%%DATE:~7,2%if exist C:\Output\output.txt (   copy /y C:\Output\output.txt "F:\Locker\SIC by Plawro\outputs\output%date%_%time%_%random%.txt" >nul   timeout 1 >nul)call C:\Tools\outputreinstall.bat
     
    Frederik Long, Oct 3, 2024
    #4
Thema:

batch file is not working

Loading...
  1. batch file is not working - Similar Threads - batch file working

  2. Batch File

    in Windows 10 Software and Apps
    Batch File: Hi, I am trying to create a batch file to determine whether a user account is signed on.I don't have enough experience to get it to @Echo it worked. Any advice please.Batch file:REM Query whether user SBackup is active@echo onsetlocal enabledelayedexpansionset...
  3. Batch Files

    in Windows 10 Gaming
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  4. Batch Files

    in Windows 10 Software and Apps
    Batch Files: How do i make it that my batch file puts itself in to startup https://answers.microsoft.com/en-us/windows/forum/all/batch-files/6156404d-20d4-4f58-bee5-14629dbf7b10
  5. Allow batch file renamer to work?

    in Windows 10 Network and Sharing
    Allow batch file renamer to work?: I'm trying to use a batch file renamer in order to add terms to the beginning of a file:picture1.jpgpicture2.jpgadd "2022 - " to the beginning to give:2022 - picture1.jpg2022 - picture2.jpgFirst off, I'd like a suggestion as to a safe one to use. Free is obviously preferable,...
  6. Allow batch file renamer to work?

    in Windows 10 Gaming
    Allow batch file renamer to work?: I'm trying to use a batch file renamer in order to add terms to the beginning of a file:picture1.jpgpicture2.jpgadd "2022 - " to the beginning to give:2022 - picture1.jpg2022 - picture2.jpgFirst off, I'd like a suggestion as to a safe one to use. Free is obviously preferable,...
  7. Allow batch file renamer to work?

    in Windows 10 Software and Apps
    Allow batch file renamer to work?: I'm trying to use a batch file renamer in order to add terms to the beginning of a file:picture1.jpgpicture2.jpgadd "2022 - " to the beginning to give:2022 - picture1.jpg2022 - picture2.jpgFirst off, I'd like a suggestion as to a safe one to use. Free is obviously preferable,...
  8. Batch file not working

    in Windows 10 Network and Sharing
    Batch file not working: Hello, Iam making autorun project that if I plug Flash disc in my pc it autoruns batch file with my "assistant" what says Hi, what do you want? But here are things that just doesn´t work: 1.If I plug in the Flash disc autorun.inf dont do anything. 2.If I manage batch file...
  9. Create batch files with Batch?

    in Windows 10 Software and Apps
    Create batch files with Batch?: How to create Batch and VBS files with Batch? So I write a batch file which I then convert to exe that creates new folders in a certain directory and then creates batch and VBS files with a certain content and saves them in the created folder. So it's similar to a program...
  10. Batch File

    in Windows 10 Support
    Batch File: I need a batch file to create a folder with sub folders. The sub folders will be named the current date, they will go in a folder on c drive. For example we can call the folder test and it would be in documents on c drive. Every time we run the batch file it would create a...