Windows 7 set system date/time in batch - windows

I have a batch file which I need to run at a specific date in the past. I can do this manually by changing the system date and time via the Control Panel (image below), running the batch file, and setting the date back to the current date. However, I would like to include setting time and date within my batch file to simplify the process. Is this possible?

The DATE command can be used to set the date in Windows 7.
The following, in US-locale, all have the same effect; to set the clock to December 3, 2012:
DATE 12/3/2012
DATE 12-03-2012
DATE 12/03/12
DATE 12-3-12
Note that administrator privileges are required to perform the command.

Related

Making windows time uneditable

When the windows time is set with a wrong time and a file is created,the file takes that time as date modified. Later on,when the time is corrected, the file still remains with wrong time and it is hard to understand when the file was modified. To avoid this confusion,how can the time of windows be made not to be editable.
You can prevent the time from being changed by other users by editing the local security policy. Run secpol.msc, navigate to Local Policies and to User Rights Assignments. On the right, edit the item Change the system time and Change the time zone (if required) to your liking.

Can I use a file's last committed time as the Windows Date Modified timestamp?

Is there a way to set Windows Explorer to display a file's last committed date in the Date Modified field instead of showing the last downloaded date? Or maybe an additional column that does this?
That is not possible.
Custom columns in Windows Explorer were supported until Windows XP, so there is no technical way right now.

How to start batch file at power on pc

I would need to start a batch script at boot before the user to log in with his credentials.
How could I do?
Thank you all
You can take a look at this How to launch a program before the shell (Explorer) starts.
If you want to start an application before the shell starts, you can add a value to the Userinit value in the registry. In this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
There is a value named Userinit. Change it so your program is run before userinit.exe. For example, to start notepad before the shell/everything else is initialized:
C:\WINDOWS\system32\notepad.exe,C:\Windows\system32\userinit.exe
Use commas to separate the programs that should be started.
So the same thing for your batch file just add the absolute path instead of the notepad example
There's 2 keys that you can edit from the local registry
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
If HKLM (HKEY_LOCAL_MACHINE) is modified it will affect the entire machine, so the batch file will run no matter who logs in, while HKCU (HKEY_CURRENT_USER) will only affect the currently logged in user when the registry is modified. You can also add, modify or verify the current existance of either of the above keys from your batch file, just open a command prompt and type REG /? to view available commands.
If you can edit the system's registry, you can run regedit.exe and add browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices. Add a new string value, with an arbitrary name, and the full batch path as value.
I think this will be executed every time Windows is booted. Not sure about if it will be run after awakening from an hibernation period.
Not to be mistaked with HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, which happens every time any user logs in (thanks to Harry Johnston), or HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, which happens every time a certain user logs in.

Batch Script that saves log files

I am currently using a program called USBDeviewer for auditing purposes. Basically what it does is it gets a list of USB devices that were used on a particular PC. The program can create a log file but you have to do it manually. The keyboard command to save a log file is ctrl+A to select all devices and then ctrl+S to save. After you select save you are prompted to enter a filename and location to save it.
I need a batch script that will automatically run this program and save the information on the log file to a folder automatically without any human intervention such as typing in the name (it needs a different name every time, perhaps the filename can include a different date every time).
This is a simple script but I am not familiar with batch scripting so any help would be appreciated.
Save Command-Line Options for usbdeview.exe
/stext Filename : Save the list of all USB devices into a regular text file.
#echo off
set Log=c:\temp\logfile.txt
usbdeview.exe /stext %Log%

Windows 7 O.S: unable to chnage the Date

I have set the date and time in Control Panel Date and Time Right click Run as administrator.
After I restarted the system.its giving the wrong date.
Example:
Todays date is 03/19/2012
I changed it to 03/24/2012
I reboot the system.
It displays the date as 03/19/2012
Click the Clock and click Change time and date settingsā€¦
Set the time under the Date and Time tab
And under the Internet Time tab, click Change Settings
Uncheck Synchronize time with an Internet time server. Then press OK.
Reboot now, The time must be the one that you had set(Of course it would have advanced by a couple of sec/min based on the time taken for the system to restart).

Resources