cmd

Batch- If statements based on files/websites open

◇◆丶佛笑我妖孽 提交于 2020-01-07 03:03:20
问题 In my previous question, Batch if statements based on opening a program, I asked how to make a batch if statement based on opening a program. Can I make a batch-file IF statement based off: File Paths in explorer: e.g. "C:\USERS\admin\desktop\" Files: e.g. "James.csv" Websites: e.g. "http://www.google.com" To make my question a bit clearer: @echo off Set WinProcess1=D:\PFI.vbs Set WinProcess2=c:\ Set WinProcess3=http://www.google.com :props tasklist /FI "IMAGENAME eq %WinProcess1%" | find /C

Batch File To Loop Menu

偶尔善良 提交于 2020-01-06 20:24:51
问题 I'm creating a batch file that will launch when I login to my user account. I followed this tutorial to create a batch file with a menu. It works, however, if the user enters a number that is not listed, I want it to go back to the menu. How would I implement that? Side note: I understand I could use something more flexible like Powershell, however, I prefer batch files. Here is what I have so far: @ECHO OFF CLS :MENU echo Welcome %USERNAME% echo 1 - Start KeePass echo 2 - Backup echo 3 -

Why don't Windows Shell (cmd.exe) builtin commands read from stdin?

允我心安 提交于 2020-01-06 16:18:10
问题 Why don't Windows Shell (cmd.exe) built-in commands read from stdin? (or so it seems) Example: echo bar | set /p foo= 回答1: SET /P does read the input from the pipe, but it doesn't do any good because both sides of the pipe are executed within new cmd.exe processes. So the newly defined variable is lost once the pipe sub-processes terminate. For more information, see the selected answer to the Stack Overflow question - Why does delayed expansion fail when inside a piped block of code? 来源:

How do I get raw VBScript command line arguments? [duplicate]

血红的双手。 提交于 2020-01-06 15:41:56
问题 This question already has answers here : What is the %* or $* argument list equivalent for VBScript? (2 answers) Closed 3 years ago . How do I get the entire command line in a .vbs file? I'm looking to process it myself, with all special characters/quotes still intact. For example, the command: cscript.exe example.vbs /month:April /price:500 "Joe Smith" is "our" guy I am NOT interested in: WScript.Arguments.Named.Item("month") = April WScript.Arguments.Item(2) = Joe Smith Dim StrArgs For Each

Subtract month in Windows batch

对着背影说爱祢 提交于 2020-01-06 15:11:26
问题 I would like to have this run and show the previous month. When I try to subtract the month it makes the last day of the month field not appear. @echo off set FirstDay=01 set Month=%date:~4,2% set Year=%date:~10,4% if %Month%==01 set LastDay=31 & goto foundate if %Month%==02 set LastDay=28 & goto foundate if %Month%==03 set LastDay=31 & goto foundate if %Month%==04 set LastDay=30 & goto foundate if %Month%==05 set LastDay=31 & goto foundate if %Month%==06 set LastDay=30 & goto foundate if

Compiling C++ in cmd using MinGW on Windows 8

北城以北 提交于 2020-01-06 14:43:11
问题 I'm trying to compile c++ programs from the commandline, but I can't. I tried all the steps and instructions listed here. I got MinGW installed, but I get stuck in the last step of the installation that explains how to change environment paths. There simply isn't PATH part of it on the environment variables, and when I try to add it or even edit the one in System variables, compiling doesn't work (nothing comes up when I type g++ on the command prompt). I've searched online for solutions, but

Colored Python Prompt in Windows?

☆樱花仙子☆ 提交于 2020-01-06 08:37:28
问题 Here's my script that currently sets up my prompts for all of my computers (whether they're Windows, Red Hat, or OS X): import sys import datetime import platform if platform.system() is 'Windows': tealUText = "" tealText = "" greenText = "" defaultText = "" else: tealUText = "\001\033[4;36m\002" tealText = "\001\033[0;36m\002" greenText = "\001\033[0;32m\002" defaultText = "\001\033[0;0m\002" class ClockPS1(object): def __repr__(self): now = datetime.datetime.now() clock = str(now.strftime("

Loop that appends filename when copying same filename from different folders to a new folder

此生再无相见时 提交于 2020-01-06 07:24:11
问题 I have the following code to search for a specific file name (ratings.zil) across multiple folders and copy them to a new folder: for /R %f in (ratings.zil) do @IF EXIST %f copy "%f" "C:\here" But when the file copies to the new folder it overwrites instead of appending a number at the end of each ratings.zil – i.e. ratings(1).zil , ratings(2).zil . Is there a way to add a loop to the above code that will append a number after each file? This question was originally marked as a duplicate,

translate CMD FTP request to PowerShell FTP request

女生的网名这么多〃 提交于 2020-01-06 07:17:33
问题 I have a fully-working FTP request saved to a .CMD file. Here is my CMD script: @echo off setlocal set uname=exUsername set passw=exPassword set hostname=exHostname set filespec=exSpec echo %uname%> test.ftp echo %passw%>> test.ftp echo pwd>> test.ftp echo cd exDir>> test.ftp echo binary>> test.ftp echo get %filespec%>> test.ftp echo bye>> test.ftp ftp -s:test.ftp %hostname% if errorlevel 1 pause endlocal I want to translate the above code to a PowerShell script. Here is my PowerShell script:

Windows batches in Cygwin with spaces in path and arguments

拥有回忆 提交于 2020-01-06 07:16:25
问题 Consider this dummy Windows batch script: echo %1 Supposed just to echo to the terminal its first argument. Assume its path in resp. Windows, Cygwin style is: c:\test\win.bat /cygdrive/c/test/win.bat From Cygwin bash: $ c:\test\win.bat "hello world" "hello world" So quotes correctly identify a single argument. But now let us introduce spaces in path: "c:\te st\win.bat" /cygdrive/c/te\ st/win.bat Then: $ /cygdrive/c/te\ st/win.bat "hello world" Gives: "C:\te" is not recognized as an internal