Questions tagged [doskey]

Windows command that recalls previously entered command-line commands, edits command lines, and creates command macros. Cannot be used in a batch file.

Documentation:

54 questions
3
votes
2 answers

mkdir && cd windows alias

I am trying to make a directory and immediately change into it with a DOSKEY. I thought this would work but it gives me the error The filename, directory name, or volume label syntax is incorrect. DOSKEY md=mkdir $* && cd $* Does anyone know why…
SirParselot
  • 2,640
  • 2
  • 20
  • 31
2
votes
1 answer

doskey to print `$env:Path -split ';'` (in PowerShell), except that doesn't work

Entering $env:path at the prompt correctly returns: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;... Entering $env:Path -split ';' at the…
DavidT
  • 655
  • 7
  • 19
2
votes
2 answers

DOSKEY macros break prompts (SET /P) of batch scripts, when run from within same Windows CMD shell

Yes, it's 2021 and I'm still using the CMD shell and batch scripts for simple tasks. I just recently tried to enhance my workflow by auto-running my own init-script for (each) CMD prompt session, which also includes setting a bunch of DOSKEY…
e.d.n.a
  • 191
  • 1
  • 6
2
votes
1 answer

Why %cd% set in doskey alias script returns script path instead of the current directory

I am setting an alias file in %userprofile%\alias.cmd containing basic DOSKEY cmd: @echo off DOSKEY ls=dir DOSKEY clear=cls DOSKEY pwd=echo %cd% I am installing alias.cmd in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor, such as described…
tim
  • 73
  • 1
  • 7
2
votes
1 answer

Use alias to run a loop

I would like to be able to manually type an 'alias' keyword into the command console and have it execute the following command a specified number of times. taskkill /PID "%PID%" /f >nul 2>&1 I found this command which will run a loop: for /l %x in…
Pemhoo
  • 109
  • 5
2
votes
4 answers

Copying file path of current directory in CMD(DOSKEY)

I'm writing DOSKEY with multiple commands, separated by $T, and I need to copy PATH of current directory to cipbord(so I could use it latter outside of CMD) and to continue with commands. I have tried chdir | clip by it brakes commands after.…
IGRACH
  • 3,506
  • 6
  • 33
  • 48
1
vote
1 answer

Sanitizing command parameters in a DOSKEY macro

Let's say I have the following in my AutoRun script: @doskey cd = @( ^ for /f usebackq^^ delims^^=^^ eol^^= %%a in (^ '$* ' ^ ) do @( ^ if "%%~a"==" " ( ^ if /i not "%%CD%%"=="%%USERPROFILE%%" ( ^ …
mataha
  • 155
  • 7
1
vote
1 answer

Get date/time of commands from history on windows (cmd/ps)

https://www.2daygeek.com/display-date-time-linux-bash-history-command/ Found this article which seems to show equivalent how to for linux, using HISTTIMEFORMAT environment variable, # history 1 2017-08-16 15:30:15 yum install -y mysql-server…
1
vote
1 answer

how to escape findstr /r in a for loop to work in doskey

I have this command for /F "tokens=2 delims=:" %a in ('ipconfig ^| findstr /R "Default Gateway[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"') do @ping -t %a this works fine and extracts my default gateway and pings it I would like to wrap this into a doskey…
1
vote
1 answer

`doskey /macros:all` produces quoted string I can't get rid of

First, I'm in PowerShell and I've entered the doskey /exename=powershell.exe option. Second, I did something that I now realize doesn't quite work: doskey envpath=$env:Path -split ';' The goal was to have it print the path environment variable…
DavidT
  • 655
  • 7
  • 19
1
vote
1 answer

Windows Batch Files: How can I append to a *.bat or *.cmd file from within itself?

I'm trying to implement a slight modification to the code provided by @Argyll in this SO answer, specifically changing: DOSKEY alias=notepad %USERPROFILE%\Dropbox\alias.cmd to: doskey alias=echo doskey $*>>%0 But the redirection fails when I use…
Kenny83
  • 769
  • 12
  • 38
1
vote
0 answers

How to keep alias setting with doskey in Azure pipeline?

I am using Azure pipeline with Self-hosted Windows agents to run a local script init.cmd, which is mainly for alias setting with doskey. I am using the following YAML file to configure the pipeline trigger: - master pool: $(AGENT_POOL) steps: -…
licaomeng
  • 919
  • 2
  • 13
  • 27
1
vote
1 answer

How to escape all quotes in $* to pass it to PowerShell from CMD

I experience some problem with executing PowerShell command from CMD. I have a function MyFunction in PowerShell which takes two parameters: Id and Text. Example: MyFunction 12345 "Name = Karl" I need to call this function from CMD: powershell…
1
vote
2 answers

How to make an alias for a function in batch?

I want to create an alias for a function in batch something like this: echo off DOSKEY getMessage=call :message :message SET answer= SET /P answer=What is your message? : IF EXIST %answer% ( echo %answer% ) else( goto mesage ) I don't…
Mindru Ion
  • 373
  • 5
  • 19
1
vote
1 answer

How to create a DOSKEY alias command to print Windows %PATH% with every entry on new line?

I have the same task as Print Windows %PATH% with every entry on new line I have a task: print all entries of %PATH% variable on new line. For example: C:\Program Files\ C:\Windows C:\Windows\System32 and so on... which is achievable by echo…
LPVOID
  • 306
  • 3
  • 17