Unfortunately my time service is broken and I was not able to restore it. So I wrote a batch script which invokes a powershel script which starts the time service and put that inside the autostart foldert. Time Serive has been starting since then but unfortunately I got prompted everytime my computer boots. In additon both files are opened in editor. How can I possibly avoid this?
Batch:
@ECHO OFF
set "params=%*"
cd /d "%~dp0" && ( if exist "%temp%getadmin.vbs" del "%temp%getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && ""%~s0"" %params%", "", "runas", 1 >> "%temp%getadmin.vbs" && "%temp%getadmin.vbs" && exit /B )
Powershell.exe -NoProfile -executionpolicy bypass -File "C:UserssomenameAppDataRoamingMicrosoftWindowsStart MenuProgramsStartupTimeServiceStart.ps1"
Powershell:
$datetime = Get-Date
$DateStr = '{0:yyyy.MM.dd_hh.mm.ss}' -f $datetime
Start-Transcript -Path "C:UserssomenameScriptLogsLog_${DateStr}.txt"
net start w32time
I tried to run it without admin rights which results in an error logged in the logfile “access denied”.
Dark_Joe ha2k3r is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.