(view source code of nostartskype.bat as plain text)
@ECHO OFF
ECHO.
ECHO NoStartSkype.bat, Version 1.01 for Windows 7 and later
ECHO Disable Skype to start when Windows starts, reenforce after Skype updates
ECHO.
ECHO Usage: NOSTARTSKYPE.BAT
ECHO.
ECHO Notes: This batch file has to be run only once on the computer, with
ECHO elevated privileges.
ECHO The batch file uses a temporary XML file to create a Scheduled
ECHO task, which in turn will delete Skype's autostart entry in the
ECHO registry at each logon and at each workstation lock event.
ECHO Return code ^("ErrorLevel"^) 0 if all seems to go well, 1 for
ECHO invalid command line arguments, 2 if a restart with elevated
ECHO privileges was required.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
ECHO.
ECHO.
IF "%~1"=="" (
REM Check if running with elevated privileges
WHOAMI /Groups 2>NUL | FIND "12288" >NUL
IF ERRORLEVEL 1 (
REM Create a temporary script to restart the batch file with elevated privileges
> "%Temp%.\%~n0.vbs" ECHO Set UAC = CreateObject^( "Shell.Application" ^)
>> "%Temp%.\%~n0.vbs" ECHO UAC.ShellExecute "%~s0", "", "", "runas", 1
REM Restart the batch file with elevated privileges
CSCRIPT.EXE //NoLogo "%Temp%.\%~n0.vbs"
EXIT /B 2
)
SLEEP 5 >NUL 2>&1
REM Delete temporary script if it exists
IF EXIST "%Temp%.\%~n0.vbs" DEL "%Temp%.\%~n0.vbs"
) ELSE (
EXIT /B 1
)
SETLOCAL
REM Use WMIC to capture task creation time
FOR /F "tokens=*" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Year /Format:Value ^| FIND "="') DO (
FOR /F "tokens=1* delims==" %%B IN ("%%~A") DO (
SET %%~B=0%%~C
)
)
REM Create (Unicode) XML file to import scheduled task from
SET XML="%Temp%.\%~n0.xml"
IF EXIST %XML% DEL %XML%
> %XML% ECHO ^<?xml version="1.0" encoding="UTF-16"?^>
>> %XML% ECHO ^<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"^>
>> %XML% ECHO ^<RegistrationInfo^>
>> %XML% ECHO ^<Date^>%Year:~1%-%Month:~-2,2%-%Day:~-2,2%T%Hour:~-2,2%:%Minute:~-2,2%:00.000^</Date^>
>> %XML% ECHO ^<Author^>%UserDomain%\%UserName%^</Author^>
>> %XML% ECHO ^</RegistrationInfo^>
>> %XML% ECHO ^<Triggers^>
>> %XML% ECHO ^<SessionStateChangeTrigger^>
>> %XML% ECHO ^<Enabled^>true^</Enabled^>
>> %XML% ECHO ^<StateChange^>SessionLock^</StateChange^>
>> %XML% ECHO ^</SessionStateChangeTrigger^>
>> %XML% ECHO ^<LogonTrigger^>
>> %XML% ECHO ^<Enabled^>true^</Enabled^>
>> %XML% ECHO ^</LogonTrigger^>
>> %XML% ECHO ^</Triggers^>
>> %XML% ECHO ^<Principals^>
>> %XML% ECHO ^<Principal id="Author"^>
>> %XML% ECHO ^<UserId^>%UserDomain%\%UserName%^</UserId^>
>> %XML% ECHO ^<LogonType^>InteractiveToken^</LogonType^>
>> %XML% ECHO ^<RunLevel^>HighestAvailable^</RunLevel^>
>> %XML% ECHO ^</Principal^>
>> %XML% ECHO ^</Principals^>
>> %XML% ECHO ^<Settings^>
>> %XML% ECHO ^<MultipleInstancesPolicy^>IgnoreNew^</MultipleInstancesPolicy^>
>> %XML% ECHO ^<DisallowStartIfOnBatteries^>false^</DisallowStartIfOnBatteries^>
>> %XML% ECHO ^<StopIfGoingOnBatteries^>true^</StopIfGoingOnBatteries^>
>> %XML% ECHO ^<AllowHardTerminate^>true^</AllowHardTerminate^>
>> %XML% ECHO ^<StartWhenAvailable^>false^</StartWhenAvailable^>
>> %XML% ECHO ^<RunOnlyIfNetworkAvailable^>false^</RunOnlyIfNetworkAvailable^>
>> %XML% ECHO ^<IdleSettings^>
>> %XML% ECHO ^<StopOnIdleEnd^>true^</StopOnIdleEnd^>
>> %XML% ECHO ^<RestartOnIdle^>false^</RestartOnIdle^>
>> %XML% ECHO ^</IdleSettings^>
>> %XML% ECHO ^<AllowStartOnDemand^>true^</AllowStartOnDemand^>
>> %XML% ECHO ^<Enabled^>true^</Enabled^>
>> %XML% ECHO ^<Hidden^>true^</Hidden^>
>> %XML% ECHO ^<RunOnlyIfIdle^>false^</RunOnlyIfIdle^>
>> %XML% ECHO ^<DisallowStartOnRemoteAppSession^>false^</DisallowStartOnRemoteAppSession^>
>> %XML% ECHO ^<UseUnifiedSchedulingEngine^>false^</UseUnifiedSchedulingEngine^>
>> %XML% ECHO ^<WakeToRun^>false^</WakeToRun^>
>> %XML% ECHO ^<ExecutionTimeLimit^>PT1H^</ExecutionTimeLimit^>
>> %XML% ECHO ^<Priority^>7^</Priority^>
>> %XML% ECHO ^<RestartOnFailure^>
>> %XML% ECHO ^<Interval^>PT5M^</Interval^>
>> %XML% ECHO ^<Count^>3^</Count^>
>> %XML% ECHO ^</RestartOnFailure^>
>> %XML% ECHO ^</Settings^>
>> %XML% ECHO ^<Actions Context="Author"^>
>> %XML% ECHO ^<Exec^>
>> %XML% ECHO ^<Command^>REG.EXE^</Command^>
>> %XML% ECHO ^<Arguments^>Delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /V Skype /F^</Arguments^>
>> %XML% ECHO ^</Exec^>
>> %XML% ECHO ^</Actions^>
>> %XML% ECHO ^</Task^>
REM Delete the task if it already exists
SCHTASKS /Query /TN "%~n0" >NUL 2>&1 && SCHTASKS /Delete /TN "%~n0" /F >NUL 2>&1
REM Create the task by importing the XML we just created
SCHTASKS /Create /TN "%~n0" /XML %XML%
REM Delete the temporary XML file
IF EXIST %XML% DEL %XML%
ENDLOCAL
EXIT /B 0
page last modified: 2024-04-16; loaded in 0.0110 seconds