Command a loop for Batch file [closed] - windows

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is it possible to execute ping.exe file every 2 minutes one by one in a loop.
The BAT file can be like:
programme.exe
--server firstxyzdomain.com --port 4040
RUN IT FOR 2 MINUTES
THEN PAUSE
THEN EXECUTE OTHER COMMAND
--server SECONDxyzdomain.com --port 20595
RUN IT FOR 2MINUTES
THEN PAUSE
LOOPBACK & resume

Yes. Create a list of devices, ping them using the -n option as provided by ping
#echo off
:start
set "myips=localhost,127.0.0.1,google.com"
for %%a in (%myips%) do ping %%~a -n 121
goto :start

Related

Replace special characters using Windows batch script [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
I am trying to replace these special characters using Windows batch scripting.
Existing
To
My "name" is XXXX
My \"name\" is XXXX
My name is XXX\X
My name is XXX\\X
I tried to achieve this through Informatica Cloud. It is not working, so I am trying to create one single code for these scenarios.
Try drag and drop your input file over this batch script using regex in powershell to replace the special char :
#echo off
Title Replace Some Special Char
Set "InputFile=%1"
If [%InputFile%] EQU [] echo/ You should Drag and Drop an Inputfile over this batch script "%~nx0" & TimeOut /T 8 /NoBreak>nul & exit /b 1
Powershell -Command "(gc '%InputFile%' -raw) -replace '([\"\\])', '\$1' ^| Out-File output.txt"
Start "" output.txt

Request help for a batch script to kill a process after a program is closed [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
How do I modify the following batch script to kill a process instead of a task?
For example, if BBB.exe once executed runs as a process, how would I kill that process once AAA.exe is closed?
To clarify, if you open task manager, tasks are listed under the "applications" tab and a process is listed under the "processes" tab. The program represented as "BBB.exe" that I'm trying to kill immediately once AAA.exe is closed only opens to the system tray and not the task bar and therefore is not present in the "applications" tab but only the "processes" tab when open. The following batch file does not have any effect on ending program "BBB.exe" even when the machine is ran with admin privileges. I've seen the "Process.Kill()" command but I'm not sure how to properly utilize it.
Thanks in advance.
#Echo off
CD "C:\Users\XXX\XXX\XXX"
start AAA.exe
CD "C:\XXX\XXX"
start BBB.exe
:TEST
Tasklist /FI "IMAGENAME eq AAA.exe" 2>NUL | Find /I /N AAA.exe>NUL
If "%ERRORLEVEL%"=="0" goto ACTIVE
:DEAD
Taskkill /F /IM BBB.exe
Exit
:ACTIVE
Timeout /T 1
Goto TEST
I found out what the problem is.
The issue lies in that the "taskkill" command was never being deployed because command prompt remained in the directory of BBB.exe where the "taskkill" executable doesn't exist.
Simply changing the directoy to either "system32" or "syswow64" (depending on the OS installation) after executing both programs and before running the "taskkill" command in the batch file solved the issue.

Notepad++ NppExec run in cmd [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How can I make my commands run in NppExec run in cmd, as opposed to the built in console, which doesn't work with things like: "Press any key to continue", which only works when you press enter?
You want to take a look at cmd /? output and http://ss64.com/nt/. Using start along with cmd /c will give an external window and using cmd /k will keep it in the nppexec console. One thing I don't like about the /k option is that it really isn't true as 'any key' doesn't do the trick and Enter needs to be used.
Test it out with cmd /k pause and start cmd /c pause.
Notice the start option has the window close, so any history will go away too. If that's important then substitute /k for the /c and use exit when done.

Can VBScript do what I want? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Having never used VBScript before, I just want to make sure I'm headed down the right path before I launch into it.
I need to create a process that will run via Windows Scheduler on a weekly basis.
I need the script to do the following:
Call PSFTP.exe and open a SSH session to a SFTP site, download a file and save it in a particular folder.
Unzip the files after download.
Open Truecrypt and mount encrypted volumes.
Activate a few other processes via the cmd line, in order.
All of this needs to be in order and each step needs to wait for the previous step to finish.
Can I achieve this using VBScript or a combination of VBScript and BAT files? Or should I be going down a different route?
Thanks in advance!
GPC
in its simplest form, what you want may be achieved with this short BAT file
::: C:\DEST\SO.BAT :::
pushd c:\dest
echo cd downloads > psftp.scr
echo get file.zip >> psftp.scr
echo quit >> psftp.scr
psftp user#domain.com -pw password -b psftp.scr
7z x -o file.zip
truecrypt /q /v myvolume
and schedule it to run every monday with this command
AT 09:00 /EVERY:MONDAY C:\DEST\SO.BAT
or (thanks, iesou!) in case you need specific user rights, want a task specific name... with
schtasks /create /SC Weekly /MO 1 /D Friday /TN "File Download and Extract" /TR "C:\DEST\SO.BAT" /ST 09:00 /RU PCNAME\USER /RP PASSWORD

How to change File and Folder permissions on Windows 7 using Command Line (CLI)? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am trying to use chmod utility on windows command line but it does not work. I am looking for the command to change the files and folder permission on windows.
The following commands will help to take the ownership of the directory and files:
D:\>takeown /f D:\path\to\directory /r /d y
D:\>icacls D:\path\to\directory /grant administrators:F /t

Resources