Skip to main content
21 votes
Accepted

Specify route to an interface in Windows cmd

To specify the interface in windows route command, you are supposed to use 'IF'... Uppercase letters, not lowercase. Also, where you are specifying you want to add a route to a single IP 192.168.0.6, ...
Dre's user avatar
  • 1,834
18 votes
Accepted

call batch file and run using its own path/directory

You are a bit unclear where app1.exe is located. If it shares the folder with run1.bat change run1.bat to either @Echo off Pushd "%~dp0" app1.exe popd or @Echo off "%~dp0app1.exe" %0 refers to ...
LotPings's user avatar
  • 1,035
13 votes

Current date in the file name

The only reliable way to get appropriate date whatever regional setting are, is the solution from foxidrive @ https://stackoverflow.com/questions/11037831/filename-timestamp-in-windows-cmd-batch-...
Eric Ouellet's user avatar
12 votes

Windows command prompt: how to get the count of all files in current directory?

The fastest method I have found is to run the following in the PS console. [System.IO.Directory]::GetFiles($path).Count where $path is a local path or UNC share.
John Brooks's user avatar
11 votes

Specify route to an interface in Windows cmd

This should work:  route add 192.168.0.6 mask 255.255.255.0 192.168.0.254 If you want persistence: route -p add 192.168.0.6 mask 255.255.255.0 192.168.0.254 Not sure what the "if" was for, ...
Anthony Fornito's user avatar
11 votes

Entering local admin username and password in a script

Start your batch: powershell.exe -Command "Start-Process cmd -Verb RunAs" ... rest of script ... This will open an elevated command prompt Keep in mind for this to work the user would need to have ...
Anthony Fornito's user avatar
10 votes

Rename files to add date modified to filename with Windows CMD or simple .TXT

In Powershell you can do this with a One-Liner: Get-ChildItem |Foreach-Object { Rename-Item $_ -NewName ("{0}-{1}{2}" -f $_.BaseName,$_.LastWriteTime.ToString('yyyyMMdd'),$_.Extension) } ...
Gerald Schneider's user avatar
8 votes
Accepted

How do you check what version of Server Message Block client a workstation is using on Windows?

If you have Windows 8.1 or 2012, you can use the PowerShell cmdlet Get-SmbConnection for that. To interpret the answer (copied and pasted from here): SMB 1 - Windows 2000 SMB 2 - Windows ...
Katherine Villyard's user avatar
8 votes
Accepted

NET USE command doesn't authenticate when credentials are passed as parameters

Two things: the password should precede the username, and the username should include the users domain name. NET USE * <link> <password> /USER:<userdomain>\<user>
Larryc's user avatar
  • 315
7 votes
Accepted

get AD group path in the domain/tree

2 ways so far: canonical name: get-adgroup -identity "your group" -properties canonicalname | sel -property canonicalname [enter] canonicalname Your.Domain/ou name/ou name/your group using the ...
natxo asenjo's user avatar
  • 5,819
7 votes
Accepted

Windows: Find out which process spawned another process

You can use wmic process get Caption,ParentProcessId,ProcessId for a list in command line. Or use Process Explorer from the SysInternals Suite for a GUI option.
Lenniey's user avatar
  • 5,310
7 votes

Running windows container's command prompt in admin mode

As per the Windows Containers documentation, the Windows Server Core has ContainerAdministrator as the default user whereas Windows NanoServer has ContainerUser as the default user. Thanks to Peter's ...
Harsh Rawat's user avatar
6 votes

Get PowerShell command output as a variable in bat (cmd) script

You need to escape parenthesis inside the subject when using FOR \F FOR /F "tokens=* USEBACKQ" %%F IN (`powershell.exe -noninteractive -command [System.Net.Dns]::GetHostByName^(^($env:computerName^)^)...
Kevin K.'s user avatar
  • 383
6 votes
Accepted

How can I get the list of app pool using appcmd.exe

below command, get the list of the application pools: %systemroot%\system32\inetsrv\AppCmd.exe list apppool
User12's user avatar
  • 109
5 votes

How to make the task scheduler display the cmd shell when invoking a batch file?

After reading your post and requirement which I found matching mine requirements too. I did follow the following steps and could able to get my batch script running on desktop (in foreground); Under "...
Ashish Sarraf's user avatar
5 votes
Accepted

Command line tool for listing audit policy settings

It depends if legacy (aka "category level") or advanced audit policies are in effect. For legacy audit policies (what your screenshot shows): secedit.exe /export /areas SECURITYPOLICY /cfg ...
Greg Askew's user avatar
  • 36.8k
5 votes
Accepted

Creating a new AD LDS instance without the Setup Wizard?

Yes, the "secret sauce" is a command called AdamInstall.exe, which can be run to perform unattended instance setups. You can run AdamInstall.exe on Server Core. Begin by creating this answer text file....
Jim B's user avatar
  • 24.1k
5 votes
Accepted

How to get all processes under a session of a particular process that is using a port in Windows cmd

That's actually pretty easy in PowerShell: # Get the process of the listening NetTCPConnection and the session ID of the process $SessionId = (Get-Process -Id (Get-NetTCPConnection -State Listen -...
Gerald Schneider's user avatar
4 votes

Open a new cmd console on Windows 2012 Server core after closing the last one?

I was just in that situation to get that prompt over RDP and using a boot camp MacbookAir with reduced keyboard and want to share. in this case it is: fn+ctrl+alt + (->) (Arrow right key)
Falco Alexander's user avatar
4 votes

System error 1219 has occurred

I have found that if I mount a drive, disconnect, and then try to reconnect with different credentials, this error pops up. net use * /del did not help. net use shows no connections (checked with ...
Jorge Yanes Diez's user avatar
4 votes

Given a PID on Windows - how do I find the command line instruction that executed it?

To complement Ryan Ries' helpful PowerShell answer with a shorter alternative via the -Filter parameter that also uses Get-CimInstance instead of the deprecated-since-v3 Get-WmiObject cmdlet. # Target ...
mklement's user avatar
  • 586
4 votes
Accepted

net files vs openfiles IDs

So three years later, I've found an answer and a solution, or workaround: this is a bug of the default output of openfiles, which is table. If you specify the options /FO CSV or /FO List, IDs are ...
curropar's user avatar
  • 641
4 votes

How to check if a specific list of user accounts are disabled in AD, using powershell v2.0 or CMD / VBS

PowerShell Get-ADUser -Identity SamAccountName returns the user object for SamAccountName. To get the enabled property, use: Get-ADUser -Identity SamAccountName | Select-Property Enabled. ...
Jeter-work's user avatar
4 votes

How to get the screen resolution in windows 10 with command prompt or powershell

As stated at https://stackoverflow.com/questions/7967699/get-screen-resolution-using-wmi-powershell-in-windows-7 PS> Add-Type -AssemblyName System.Windows.Forms PS> [System.Windows.Forms.Screen]...
Felipe Martinez Pineda's user avatar
4 votes
Accepted

winrm access denied for new user

There are many posts about this exact error message. Here are some excerpts that should help! #LMGTFY :) From a Symantec KB: https://support.symantec.com/en_US/article.TECH200047.html This error ...
Sam Erde's user avatar
  • 3,469
4 votes

WHy is tracert working even though I changed my DNS settings to use a bad nameserver?

The answer to this question, as noted by @BrennenSmith, is that the DNS information is stored in the DNS cache file. As seen in the output of the nslookup command, the Non-authoritative answer ...
B00TK1D's user avatar
  • 685
4 votes

Windows Command net user output

That can be either a scheduled task or a windows service that is configured to run under Administrator account. Check both. Might be a remote connection from other server too.
Net Runner's user avatar
  • 6,249
4 votes

call batch file and run using its own path/directory

The answer to your question can be drawn from a similar question on Stack Overflow. What is the current directory in a batch file? Using the variables mentioned here, you can update run1.bat to call ...
Sam Erde's user avatar
  • 3,469
4 votes
Accepted

Create a domain GPO with cmd only

Yes, it is possible, using New-GPO command on powershell. On a modern Windows 10 client with rsat tools installed and also adding Module: grouppolicy in powershell. You can execute commands to ...
Krackout's user avatar
  • 1,575
3 votes

Is there a global, persistent CMD history?

Yes, it's possible If all you want to do is save your command line history at the end of every session, here's a simple way to do it: As other answers indicated, doskey allows you to list the command ...
pbarney's user avatar
  • 131

Only top scored, non community-wiki answers of a minimum length are eligible