0% found this document useful (0 votes)
10 views1 page

Admin Script for Date Format Detection

Example for run App's that need date

Uploaded by

AmR EiSa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Admin Script for Date Format Detection

Example for run App's that need date

Uploaded by

AmR EiSa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

@echo off

:: Check if the script is running as Administrator


NET SESSION >nul 2>&1
if %errorLevel% NEQ 0 (
echo Requesting administrative privileges...
powershell -Command "Start-Process '%~f0' -Verb runAs"
exit /b
)

:: Detect the current date format (MM-dd-yyyy or dd-MM-yyyy) using PowerShell


for /f %%A in ('powershell -Command "(Get-
Culture).[Link]"') do set "dateFormat=%%A"

:: Set the date based on detected format


if "%dateFormat%"=="M/d/yyyy" (
:: Format is MM-dd-yyyy, set date to 07-15-2023 (July 15, 2023)
date 07-15-2023
) else (
:: Format is dd-MM-yyyy, set date to 15-07-2023 (15 July 2023)
date 15-07-2023
)

:: Get the current folder where the script is running


set "scriptDir=%~dp0"

:: Start the [Link] program located in the 'AndroidUtility' folder


inside the same folder as the script
start "" "%scriptDir%\AndroidUtility\[Link]"

:: Add a delay to allow the program to run for a while before resetting the date
timeout /t 0

:: Restart the Windows Time service to ensure it's running


net stop w32time
net start w32time

:: Sync the date to the current time using the Windows time service
w32tm /resync

:: Exit the script


exit

You might also like