Search found 5 matches
- 2024-Jan-12, 1:42 pm
- Forum: Windows CMD Shell
- Topic: How to replace the script name %~n0 with a string of "-" characters of length %~n0?
- Replies: 2
- Views: 4074
Re: How to replace the script name %~n0 with a string of "-" characters of length %~n0?
Hi ;) Note : %~n0 give you only the name without the extension Test and %~nx0 give you the name with extension Test.bat :!: @echo off setlocal enabledelayedexpansion :: Get script name set "scriptName=%~nx0" :: Calculate script name length call :strLen scriptName scriptNameLen echo %script...
- 2024-Jan-01, 12:27 pm
- Forum: Windows CMD Shell
- Topic: How to make an underscore variable "-----" with the length of the argument variable?
- Replies: 2
- Views: 3312
Re: How to make an underscore variable "-----" with the length of the argument variable?
@echo off echo Script Name call :MakeUnderscore 12 echo Hello World pause exit /b ::-------------------------- :MakeUnderscore for /l %%i in (1,1,%1) do ( set /p =-<nul ) echo( Exit /B ::-------------------------- The subroutine :MakeUnderscore uses a for loop to generate a series of underscores ba...
- 2024-Jan-01, 12:10 pm
- Forum: Windows CMD Shell
- Topic: Read text from .txt file and keep to paramter
- Replies: 1
- Views: 1755
Re: Read text from .txt file and keep to paramter
This batch script reads the content of the Result.txt file and stores it in the result variable. Then, it echoes the value of the result variable to the console. @echo off setlocal set "file=Result.txt" for /f "usebackq delims=" %%a in ("%file%") do ( set "result=%...
- 2021-Oct-29, 5:19 pm
- Forum: Windows CMD Shell
- Topic: Error "TerminatorExpectedAtEndOfString" when execute a powershell code from a batch file?
- Replies: 2
- Views: 4566
Re: Error "TerminatorExpectedAtEndOfString" when execute a powershell code from a batch file?
Thank you for your reply and i just have solved this problem hereSimon Sheppard wrote: ↑2021-Oct-29, 2:57 pm See here
https://ss64.com/ps/powershell.html#longfilenames
if you are calling PowerShell from a CMD batch file and the command contains quotation marks, they must be escaped: " becomes \"
- 2021-Oct-29, 7:52 am
- Forum: Windows CMD Shell
- Topic: Error "TerminatorExpectedAtEndOfString" when execute a powershell code from a batch file?
- Replies: 2
- Views: 4566
Error "TerminatorExpectedAtEndOfString" when execute a powershell code from a batch file?
Hi ;) I want to execute a powershell code with a batch file to take a screenshot from my desktop that i found it here Take a Screenshot of a User’s Desktop with PowerShell So,When i execute it as powershell script it works without any error and works for me 5/5 but when i take it as batch file like ...