Home > Software engineering >  How can I save addresses from batch file to text?
How can I save addresses from batch file to text?

Time:02-04

I want to save this code from batch file to txt but cant. I write this code but this code not working, cant save the address how can i save "some code" like this from batch file to txt. i have many codes and need to save it at the right time from batch file to txt and not execute them just save as txt. tnq

this code want to save:

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "C:\Program Files\Windows Task\WindowsTask.bat" & Chr(34), 0
Set WshShell = Nothing

this is my solution and not working:

@echo off
(echo Set WshShell = CreateObject^("WScript.Shell"^) )> sina.txt
(echo WshShell.Run chr^(34^) & "C:\Program Files\Windows Task\WindowsTask.bat" & Chr^(34^), 0)  >> sina.txt
(echo Set WshShell = Nothing) >> sina.txt
pause

CodePudding user response:

You have far less trouble with paranthesis and escaping if you put the redirection at the beginning of the line.

@echo off
>  sina.txt echo Set WshShell = CreateObject("WScript.Shell") 
>> sina.txt echo WshShell.Run chr(34) ^& "C:\Program Files\Windows Task\WindowsTask.bat" ^& Chr(34), 0
>> sina.txt echo Set WshShell = Nothing
pause

CodePudding user response:

here is another question: use this way to create text file, but execute some code in result

this code want to save:

>> sina2.txt echo SET TodayYear=^           
  •  Tags:  
  • Related