cmd

Return users mapped drive letter from network drive remote

半腔热情 提交于 2021-01-28 04:48:44
问题 I'm trying to find a way to retrieve the users mapped drive letter from a network drive. I've read a few posts here but they all seem to be around mapping/unmapping drives, whereas I simply need to know what drive the user has that network drive mapped to. From a command prompt I use: Net Use s: for example will give me the name of the networked drive (\servershare\file\sharename\shared), however Net Use \\servershare\file\sharename\shared just gives "The command completed successfully",

Move folders in their own first letter directory

社会主义新天地 提交于 2021-01-28 04:14:44
问题 I use this script to move folders in their own first letter directory @echo off setlocal enabledelayedexpansion tree for /d %%i in (*) do ( set first=%%i set first=!first:~0,1! md !first! 2>nul if not "!first!" == "%%i" move "%%i" "!first!\%%i" ) tree First letter directory are generated by this script. For example if I have folders name like these Wachenfeldt - The Пламень - Чужие Von Stroheim - Lov first letter directory that are generated by this script could be W П V I don't test this

turn on echo temporarily

六眼飞鱼酱① 提交于 2021-01-28 03:03:45
问题 I am creating a batch file and have turned echo off with @ECHO OFF however I need to demonstrate one of the commands in the batch onscreen how would I temporarily turn on ECHO 回答1: Syntax: ECHO [ON | OFF] ECHO [Message] A simple ECHO ON should solve this mystery. 来源: https://stackoverflow.com/questions/10036250/turn-on-echo-temporarily

Windows batch script: Pipe text into a command line application

只谈情不闲聊 提交于 2021-01-28 02:23:14
问题 I'm writing a batch script to automate some 3D printing processes. Right now, my code looks like this: echo connect COM5 230400>3dprint.txt echo load 3dprint01.gcode>>3dprint.txt echo print>>3dprint.txt type 3dprint.txt | C:\Printrun\pronsole.exe So Pronsole is a command-line application that takes user-inputted commands (like connect, load and print above). Above, I've made the batch file create a text file and pass that into the application - except when it hits the EOF, this causes

Different file size between powershell and cmd [duplicate]

左心房为你撑大大i 提交于 2021-01-28 01:15:56
问题 This question already has answers here : Using redirection within the script produces a unicode output. How to emit single-byte ASCII text? (6 answers) Closed 2 years ago . I am using a little processconf.js tool to build a configuration.json file from multiple .json files. Here the command I am using : node processconf.js file1.json file2.json > configuration.json I was using cmd for a moment, but today I tried using Powershell and somehow from the same files and the same command I do have

Jenkinsfile windows cmd output variable reference

十年热恋 提交于 2021-01-27 23:45:30
问题 I'm pretty new to groovy.In my Jenkinsfile i am trying to store a windows cmd output in a variable, use it in the next command, but nothing seems to be working. This is the closest i got: pipeline { agent any stages { stage('package-windows') { when { expression { isUnix() == false} } steps { script { FILENAME = bat(label: 'Get file name', returnStdout: true, script:"dir \".\\archive\\%MY_FOLDER%\\www\\main.*.js\" /s /b") } bat label: 'replace content', script: "powershell -Command \"(gc \"

Windows 'dir' command: sort files by date when '/s' is specified

与世无争的帅哥 提交于 2021-01-27 18:53:31
问题 Goal: I want to copy the latest file with a certain extension from a "source directory" to a "destination directory" using a batch file. The latest file may be under several sub-directories within the source directory. This question/answer is exactly what I want, however it does not seem to sort when the /s option is specified (as this comment would suggest): FOR /F "delims=|" %%I IN ('DIR "K:\path\tp\source\dir\*.ext" /B /S /O:D') DO SET NewestFile=%%I copy "%NewestFile%" "C:\path\to

Batch Script not raising ERRORLEVEL on failure

两盒软妹~` 提交于 2021-01-27 16:00:27
问题 I am learning Windows batch scripting. I need to raise errors when copy, move or delete operations fail. I have made a sample script and for some reason, when the operation fails I cannot get the ERRORLEVEL to rise. I run the script and the files either do not exist or are opened in another program and stderr messages are output to console, but ERRORLEVEL never rises, why is this? Also, is there any way to pipe stderr into a variable I could check, if I cannot get ERRORLEVEL to rise? My code

Changing Pause Message

ぐ巨炮叔叔 提交于 2021-01-27 04:41:46
问题 Ok, so you know how when you type up pause in CMD, it will say 'Press any key to continue...'. How do I change that to say something like 'Press a key to proceed...'? Lastly, I was coding a batch file. I want to know what's up if I have something like: @echo off cls pause pause pause pause It seems to skip round about to pauses When you press a key. I'm curious as to know the rules of which the pauses are skipped. Thanks. 回答1: Nearly the same as Deniz Zoeteman, except this version displays

How to send input to cmd when cmd is running as administrator?

∥☆過路亽.° 提交于 2021-01-23 07:53:25
问题 I created an application that sends keyboard input to cmd.exe . This works when running cmd as a normal user but fails when cmd is run as Administrator. This is my code: Var Wnd:hwnd; begin wnd:=FindWindow('ConsoleWindowClass',0); if wnd <> 0 then begin setforegroundWindow(wnd); keybd_event(Ord('A'),0,0,0); end; end; Notice that ConsoleWindowClass is the class name of cmd . How can I send input to cmd when cmd is running as administrator? 回答1: How can I type with this code inside cmd when cmd