Command to copy current time and date to clipboard in Windows 7 - clipboard

In Windows 7 command prompt, I needed a command to copy current date and time to the clipboard. I used
time /t & date /t | clip
but it only copies the date and not the time. What should I do?

echo %date%%time% | clip
result: Mon 03/28/2016 8:34:29.34

time /t > timeanddate.txt
date /t >> timeanddate.txt
type timeanddate.txt | clip
11:14 PM
Mon 07/30/2018

Related

How to find a specific file between a date range in windows server 2012,

How to find a specific file between a date range in windows server 2012, I want to try to found a file modified before 3 months
This can be done, using forfiles:
forfiles /D +22/03/2020 /C "cmd /c echo #fname"

Log the logon Windows just one time for the day

I did a script which log everyone when users log in TSE (Windows Server 2008 R2). The script lauches with a GPO.
echo %date%;%time:~0,8%;%username% >> D:\log\log.txt
I want to log users the first time of the day.
E.g :
user1 log at 9:35 9:38 12:30 18:38 just one line in the log :
26/06/2017;09:35:00;user1
for /f %%a in ('findstr /b /c:"%date%;" "D:\log\log.txt" 2^>nul^|findstr /c:";%username%" 2^>nul') do goto nolog
echo %date%;%time:~0,8%;%username% >> D:\log\log.txt
:nolog
Find any lines that start with date;, and find any of those that end ;username. If any hits (ie user has already logged in today) then goto over the login recording. If none, execute the following line and record the new logon.
I know you have already accepted an answer, but here is a way to do it that eliminates the regional settings date format problem and ensures that it is always the format you specify.
powershell -NoProfile -Command "$(get-date -Format 'MM\/dd\/yyyy') + ';' + $(Get-Date -Format HH:mm:ss) + ';' + "$Env:USERDOMAIN" + '\' + "$Env:USERNAME"

Is it possible to combine command-line options (switches) for similar commands?

At the Windows command prompt, typing date /T & time /T will output the date and time with command-line option /T.
Time: If Command Extensions are enabled the TIME command supports the
/T switch which tells the command to just output the current time,
without prompting for a new time.
Date: If Command Extensions are enabled the DATE command supports the
/T switch which tells the command to just output the current date,
without prompting for a new date.
{date & time} /T does not work. I want the /T switch to apply to both date and time commands, without having to type it twice.

Batch file does not run after upgrading to W10

I had recently upgrade from W7 to W10 and everything seems to work but this basic batch command. Whenever I launch the file, the cmd keeps outputting "The system cannot accept the date entered"
There were no modifications to my knowledge, but perhaps there were some shifting files that happened during the upgrade, I'm not so sure.
So essentially, I need to have the batch file modify the current date since the application in question does not open correctly with the current date and reverting back to the current date a few seconds after the batch executes.
This is the batch file:
set curdate=%date%
date %date:~0,-4%2014
cd "C:\Program Files (x86)\HK-Software\IBExpert"
start ibexpert.exe
#TIMEOUT /NOBREAK /T 10
date %curdate%
The problem is that the code in that script is not compatible with the %DATE% your machine is outputting.
The following offers a quick fix as long as your machine also accepts the two digit year when setting date.
set curdate=%date%
date %date:~0,-2%14
cd "C:\Program Files (x86)\HK-Software\IBExpert"
start ibexpert.exe
TIMEOUT /NOBREAK /T 10
date %curdate%

How do I check the start time of windows/explorer from batch?

I'm attempting to get the time of when windows booted, while using batch, then change the current system time to when windows booted, execute a command, then change back to the current time. I know how to store the current time, then using that information to change back to its original time after the commands are ran, I'm just not sure how to get the time of when Windows started, or explorer since explorer starts with windows.
Example:
'Storing the current system time so we can change back to it at the end.
FOR /F "tokens=*" %%i IN ('time /t') DO SET CurrentTime=%%i
'Change System time to when Windows booted [Not sure how to do this part]
time %WindowsBootTime%
'Run Commands
'Now change back to it's original time.
time %CurrentTime%
I'm attempting to get the time of when windows booted
Use the following batch file (GetBootTime.cmd)
#echo off
setlocal
for /f %%a in ('wmic os get lastbootuptime ^| find "."') do (
set _datetime=%%a
)
set _boottime=%_datetime:~0,4%-%_datetime:~4,2%-%_datetime:~6,2% %_datetime:~8,2%:%_datetime:~10,2%
echo %_boottime%
endlocal
Example output:
> GetBootTime.cmd
2016-12-20 23:49
Further Reading
An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
for /f - Loop command against the results of another command.
wmic - Windows Management Instrumentation Command.

Resources