I'm using Tauri with React JS as frontend in WINDOWS.
And this App i'm trying to make is also for windows for now
I want to write a batch script inside user's computer then run it .
I'm making a small app which will set user's desktop wallpaper, as I came across electron then searched its alternative and choose tauri - https://tauri.app/v1/api/js/
I came to a conclusion on how to make it -
first save the image that is clicked inside user's directory which i achieved .
second was to write a batch file inside the user's directory to change the wallpaper which i half achieved as I wrote the file to selected destination but - the content of batch file is -
@echo off
set "wallpaperPath=C:\Users\<me>\OneDrive\Desktop\image.jpg"
reg add "HKCU\\Control Panel\\Desktop" /v Wallpaper /t REG_SZ /d "%wallpaperPath%" /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
in react is wrote like this using escape sequence -
const scriptContent = `@echo off\nset "wallpaperPath=C:\\Users\\<me>\\OneDrive\\Desktop\\image.jpg"\nreg add "HKCU\\Control Panel\\Desktop" /v Wallpaper /t REG_SZ /d "%wallpaperPath%" /f\nRUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters`;
but the problem is it is writing the file content like this as it returns UTF8 format (this is the saved file content from user's directory)-
@echo off
set "wallpaperPath=C:UsersmeOneDriveDesktopimage.jpg"
reg add "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "%wallpaperPath%" /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
here there is no slashes used
- The last one and Main problem is that how will I run this file as these will be depend on each other like - first image will be saved , soon after file will be written , then just after that the file will be executed.
I watched all the documents and api guides , i went through the discussion channel to find out what others had problem while using shell but in the end I'm confused on how will this work . Link to shell api - https://tauri.app/v1/api/js/shell
I tried everything I could think of, I have been working on this this small project from 5-6 days , I know this can be achieved by using other Languages but now It's a challenge to me as i spent a lot of time on this .
Once again -
- how to write file in other format to save it as i liked , as it's necessary to run.
- how can i run this file automatically after that.
IMPORTANT - any other approach is welcomed.