windows-console

How to clear selected lines in Batch instead of the whole screen?

牧云@^-^@ 提交于 2019-11-26 23:33:49
问题 When we use the pause it shows "Press any key to continue . . .". After pressing any key, the latter text remains, and the remaining text appears below it. If I use cls after pause the whole screen gets cleared. Is there any method to remove only "Press any key to continue . . ." after pressing any key? Also, how do I clear only selected lines instead of clearing the whole screen? 回答1: There are multipe solutions for this problem, but batch doesn't offer a simple one. The main problem of

Console App Terminating Before async Call Completion

筅森魡賤 提交于 2019-11-26 22:47:26
问题 I'm currently writing a C# console app that generates a number of URLs that point to different images on a web site and then downloads as byte streams using WebClient.DownloadDataAsync() . My issue is that once the first asynchronous call is made, the console app considers the program to be completed and terminates before the asynchronous call can return. By using a Console.Read() I can force the console to stay open but this doesn't seem like very good design. Furthermore if the user hits

HtmlAgilityPack & Windows 8 Metro Apps

时间秒杀一切 提交于 2019-11-26 22:09:24
问题 I'm trying to get HtmlAgilityPack to work with Windows 8 Metro Apps (Windows Store Apps). I've successfully written out all the code I need in a Windows Console App (C#) and it works perfectly for parsing the HTML I need and returning me the required string I need. // Create a new HtmlDocument and load the incoming string HtmlDocument menu = new HtmlDocument(); menu.OptionUseIdAttribute = true; menu.LoadHtml(response); HtmlNode nameToRemove = menu.DocumentNode.SelectSingleNode("//*[@id=\

Windows console %DATE% Math

▼魔方 西西 提交于 2019-11-26 17:05:31
问题 I would like to set the date in a Windows batch file to 7 days ago from today. I would like to do this in the following format. set today=%date:~10,4%-%date:~4,2%-%date:~-7,2% Any ideas how to subract the 7 day time delta here ? 回答1: I posted the description below in some site some time ago: The following Batch files convert from Date to Julian Day Number an viceversa: DATETOJULIAN.BAT: @ECHO OFF REM CONVERT DATE TO JULIAN DAY NUMBER REM ANTONIO PEREZ AYALA REM GET MONTH, DAY, YEAR VALUES FOR

C++ Executing CMD Commands

北战南征 提交于 2019-11-26 14:08:32
问题 I'm having a serious problem here. I need to execute a CMD command line via C++ without the console window displaying. Therefore I cannot use system(cmd) , since the window will display. I have tried winExec(cmd, SW_HIDE) , but this does not work either. CreateProcess is another one I tried. However, this is for running programs or batch files. I have ended up trying ShellExecute : ShellExecute( NULL, "open", "cmd.exe", "ipconfig > myfile.txt", "c:\projects\b", SW_SHOWNORMAL ); Can anyone see

How to avoid console window with .pyw file containing os.system call?

烂漫一生 提交于 2019-11-26 12:29:02
问题 If I save my code files as .pyw , no console window appears - which is what I want - but if the code includes a call to os.system , I still get a pesky console window. I assume it\'s caused by the call to os.system . Is there a way to execute other files from within my .pyw script without raising the console window at all? 回答1: You could try using the subprocess module ( subprocess.Popen , subprocess.call or whatever) with the argument shell=True if you want to avoid starting a console window

Logical operators (“and”, “or”) in DOS batch

て烟熏妆下的殇ゞ 提交于 2019-11-26 11:32:05
How would you implement logical operators in DOS Batch files? You can do and with nested conditions: if %age% geq 2 ( if %age% leq 12 ( set class=child ) ) or: if %age% geq 2 if %age% leq 12 set class=child You can do or with a separate variable: set res=F if %hour% leq 6 set res=T if %hour% geq 22 set res=T if "%res%"=="T" ( set state=asleep ) The IF statement does not support logical operators ( AND and OR ), cascading IF statements make an implicit conjunction. IF Exist File1.Dat IF Exist File2.Dat GOTO FILE12_EXIST_LABEL If File1.Dat and File1.Dat exist then jump the label FILE12_EXIST

Displaying Unicode in Powershell

放肆的年华 提交于 2019-11-26 10:28:36
问题 What I\'m trying to achieve is rather straightforward though Powershell is making it almost impossible. I want to display the full path of files, some with Arabic, Chinese, Japanese and Russian characters in their names I always get some undecipherable output, such as the one shown below The output seen in console is being consumed as is by another script. The output contains ? instead of the actual characters. The command executed is (Get-ChildItem -Recurse -Path \"D:\\test\" -Include

How to use unicode characters in Windows command line?

橙三吉。 提交于 2019-11-26 03:12:38
问题 We have a project in Team Foundation Server (TFS) that has a non-English character (š) in it. When trying to script a few build-related things we\'ve stumbled upon a problem - we can\'t pass the š letter to the command-line tools. The command prompt or what not else messes it up, and the tf.exe utility can\'t find the specified project. I\'ve tried different formats for the .bat file (ANSI, UTF-8 with and without BOM) as well as scripting it in JavaScript (which is Unicode inherently) - but

Logical operators (“and”, “or”) in DOS batch

荒凉一梦 提交于 2019-11-26 02:27:45
问题 How would you implement logical operators in DOS Batch files? 回答1: You can do and with nested conditions: if %age% geq 2 ( if %age% leq 12 ( set class=child ) ) or: if %age% geq 2 if %age% leq 12 set class=child You can do or with a separate variable: set res=F if %hour% leq 6 set res=T if %hour% geq 22 set res=T if "%res%"=="T" ( set state=asleep ) 回答2: The IF statement does not support logical operators ( AND and OR ), cascading IF statements make an implicit conjunction. IF Exist File1.Dat