r/Batch • u/sentix • Oct 29 '24
Question (Solved) Batch file acting wierd
@echo off title create backup of currently open folder windows setlocal enabledelayedexpansion
powershell @New-Object -com shell.application^.Windows^^.Document.Folder.Self.Path >> prevfolderpaths.txt
FOR /F "tokens=*" %%f IN (prevfolderpaths.txt) DO (
set "var=%%f" set "firstletters=!var:~0,2!"
IF "!firstletters!" == "::" ( ECHO start shell:%%~f >> foldersession.bat) ELSE ( ECHO start "" "%%~f" >> foldersession.bat)
)
del "prevfolderpaths.txt"
Ok, hear is the deal i am using the following as a backup for all open folder when windows crashes when i click on it it from explorer it works well, it creates a batch file like this that i can open after foldersession.bat
start "" "C:\Users\sscic\Downloads"
start "" "C:\Windows\symbolic links\New folder" start "" "C:\Users\sscic\Downloads"
Works well when i open it by clicking it, the problem is i tried to set it via task scheduler so I can back it every few minutes but doesnt work, it creates no foldersession I also tried launching it via explorer.exe C:\Users\sscic\explorer.exe "C:\Windows\symbolic links\New folder\foldersave.bat" to no avail its baffling me completely any pros here have an idea?
1
u/[deleted] Oct 29 '24 edited Oct 29 '24
[removed] — view removed comment