Running an application under another account on a Windows system with runas
If you are logged into a system running the Microsoft Windows operating system
and wish to run an application, e.g., Microsoft Outlook, under another account
other than the one you are currently logged in under without switching to that
other account, you can run the application as the other user using the
runas
command from a command prompt. If you don't know where the
application is located on the system, you can find its location from a
command
prompt by changing the directory to the root directory of the drive where
applications are stored, which is typically drive C:, then use the
/s
option of the dir
command to search all
subdirectories for the program, e.g., outlook.exe, which is the executable
file for Microsoft Outlook.
C:\Program Files\Microsoft Office>cd \
C:\>dir /s outlook.exe
Volume in drive C has no label.
Volume Serial Number is 9420-A68C
Directory of C:\Program Files (x86)\Microsoft Office\Office14
03/16/2021 12:41 AM 15,794,840 OUTLOOK.EXE
1 File(s) 15,794,840 bytes
Directory of C:\Windows\Installer\$PatchCache$\Managed\00004109D30000000000000000F01FEC\14.0.4763
03/23/2010 12:57 PM 15,889,248 OUTLOOK.EXE
1 File(s) 15,889,248 bytes
Total Files Listed:
2 File(s) 31,684,088 bytes
0 Dir(s) 3,328,741,376 bytes free
C:\>
In the example above, the program is located in the
C:\Program Files (x86)\Microsoft Office\Office14
directory, so
I can start the application as the user jdoe in the
Windows domain
Mordor with the command below (enclose the directory path and application
name in double quotes if there are spaces in the directory path):
C:\>runas /user:mordor\jdoe "C:\Program Files (x86)\Microsoft Office\Office14\Outlook.exe"
Enter the password for mordor\jdoe:
Attempting to start C:\Program Files (x86)\Microsoft Office\Office14\Outlook.exe as user "mordor\jdoe" ...
C:\>
If the account under which I wanted to run Outlook is not in a Windows
domain, but is, instead, an account on the same computer, I could omit the
domain specification and just use /user:jdoe
. You can also
use the format user@domain
, e.g., jdoe@mordor.lan
,
instead of the format domainname\username
. To run a program as
another user, you will need to know the password for the other account.
In this case, the graphical user interface (GUI) for Outlook will open with
the email, calendar entries, tasks, and contacts for the domain jdoe account
once the password for that account is provided.
[/os/windows/commands]
permanent link
Performing a bare metal backup on a Windows 10 system
If you want to perform a "bare metal" backup of a Microsoft Windows 10 system
to an external USB
drive without a third-party application, you can use the
Backup and Restore utility that is provided by Microsoft with the
operating system. You can run the program from a command-line interface
(CLI) by
opening a command prompt window with
administrator privileges and issuing the command wbadmin start
backup -backupTarget:x -allcritical -quiet
where x
is the drive letter for the drive where you wish to store the backup.
When you add the -quiet
option, the backup will be run with no
prompts for the user. The --allcritical
option "creates a backup
that includes all critical volumes (critical volumes contain the operating
system files and components)."
[ More Info ]
[/os/windows/commands]
permanent link
Deleting old Windows backups with wbadmin
I had set up the built-in Windows 7 backup utility to run on my
mother-in-law's Windows 10 PC to back up the computer's internal hard
disk drive (HDD) to an external
USB drive. She asked me to verify that the backup was
still functioning, so I checked the status of the backup process on her
Windows 10 (version 1709) system
using the wbadmin
command by
opening a command prompt
window with administrator access to run the
wbadmin get versions
command to obtain a list of all the
backups. I found that the last backup had occurred on December 31, 2017.
[ More Info ]
[/os/windows/commands]
permanent link
Checking operating system information with WMIC
You can use wmic os get
commands on a Microsoft Windows system
to view information related to the operating system via a command-line
interface (CLI). E.g., to determine the version of the operating system you
can issue the command
Windows Management Instrumentation Command-line (WMIC)
command wmic os get version
.
C:\Users\Public>wmic os get version
Version
10.0.15063
C:\Users\Public>
Or if you know the system is running a particular version of the Windows
operating system, e.g., Windows 10, but want to see just the build number
for that version of Windows, you could issue the command wmic os get
BuildNumber
.
C:\Users\Public>wmic os get BuildNumber
BuildNumber
15063
C:\Users\Public>
[ More Info ]
[/os/windows/commands/wmic]
permanent link
Determining the antivirus software on a Windows system from the command line
You can determine the antivirus software present on a system, if the
antivirus software is registered with the Windows Security Center, using
Windows Management Instrumentation Command-line (WMIC).
E.g., for a Windows 10 system using Microsoft
Windows Defender:
C:\>WMIC /Node:localhost /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct Get displayName
displayName
Windows Defender
C:\>
[ More Info ]
[/os/windows/commands/wmic]
permanent link
Displaying date and time information on a Microsoft Windows system
You can use the date and
time commands on a Microsoft Windows system to
display current date and time information:
C:\Users\Lila>date /t
Sat 08/26/2017
C:\Users\Lila>time /t
02:07 PM
C:\Users\Lila>
Placing /t
after the commands results in the current date
and time information being displayed without an accompanying prompt to change
the current settings.
You can display the information in a different format using
the
Windows Management Instrumentation Command-line (WMIC) command shown below:
C:\Users\Lila>wmic path win32_utctime get * /format:list
Day=26
DayOfWeek=6
Hour=18
Milliseconds=
Minute=16
Month=8
Quarter=3
Second=19
WeekInMonth=4
Year=2017
C:\Users\Lila>
[ More Info ]
[/os/windows/commands]
permanent link
Viewing Partition Information on a Windows System
One way to see how disks are
partitioned on a Microsoft Windws system is to
view the information using Disk Management. You can start the
utility from a command prompt with
administrator privileges by typing diskmgmt.msc
. That will provide
a graphical display of the partitions on the drives in the system and
externally attached to the system.
Another method is to use the diskpart
command, which can be run
from a command prompt - obtain a command prompt with administrator privileges.
You can obtain help on using the utility by typing help
at the
DISKPART prompt.
[ More Info ]
[/os/windows/commands]
permanent link
icacls
On Microsoft Windows Vista and
Windows Server 2003 and later systems, you can use the
Integrity Control Access Control List (icacls) program to display,
modify, backup and restore
Access Control Lists (ACLs) for files and folders. E.g.:
C:\>icacls C:\WINDOWS\system32\mmc.exe
C:\WINDOWS\system32\mmc.exe NT SERVICE\TrustedInstaller:(F)
BUILTIN\Administrators:(RX)
NT AUTHORITY\SYSTEM:(RX)
BUILTIN\Users:(RX)
APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(RX)
APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APPLICATION PACKAGES:(RX)
Successfully processed 1 files; Failed processing 0 files
C:\>
In the above example, the "RX" indicates read and execute access for the
file for the specified accounts.
[ More Info ]
[/os/windows/commands]
permanent link
Finding open files on a Windows SBS server
If you need to find files open on a
Small Business Server (SBS) system, e.g., perhaps files
have been opened on the server from other computers in the
windows domain, you can do so by taking the following steps:
-
Click on Start
-
Select Administrative Tools then select Computer Management and
then, under Sytem Tools, click on Shared Folders
-
Double-click on Open Files. You will then see the files open on the
server from other systems. You will see the files being accessed, who is
accessing them, the locks, if any, and the mode in which it files have
been accessed, e.g., whether they are open only for reading or whether they
are open in read and write mode. Right-clicking on a file will give you the
ability to close the open file.
[ More Info ]
[/os/windows/commands]
permanent link
Batch file to ping several hosts and log results
Since a connectivity issue between a Windows XP system in another country and
systems in the United States seemed to correlate with the time of day that
connectivity attempts were taking place, I wanted to have a batch file that
would periodically
ping from the source to the destination hosts and record
the results, so that I could determine if packet loss was occurring
at particular times every day because of contention with other traffic.
So I created the following batch file
(pinghosts.bat):
@echo off
set pingCount=5
set timeOut=500
set dirPath=%HOMEPATH%\Documents
REM ping google.com, apple.com, and cisco.com
for %%i in ("216.58.217.142" "17.142.160.59" "72.163.4.161") do (
if not exist %dirPath%\%%i.txt (
systeminfo | find "Time Zone:" > %dirPath%\%%i.txt
)
echo. >> %dirPath%\%%i.txt
echo %date% %time% >> %dirPath%\%%i.txt
ping -n %pingCount% -w %timeOut% %%i >> %dirPath%\%%i.txt
)
[ More Info ]
[/os/windows/commands/batch]
permanent link