Compare commits
3
Commits
0ba44cb229
...
61ea9303d3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61ea9303d3 | ||
|
|
b4396973cb | ||
|
|
740fd134d1 |
@@ -0,0 +1,60 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
cls
|
||||
|
||||
rem Temporary file to store the services we'll need to enable
|
||||
set FILENAME=safebootservices.txt
|
||||
|
||||
rem List of services that need to be started in Safe Mode with Networking
|
||||
echo AteraAgent> %FILENAME%
|
||||
echo Splashtop Inc.>> %FILENAME%
|
||||
echo SplashtopRemoteService>> %FILENAME%
|
||||
|
||||
echo.
|
||||
echo Configuring required services to automatically start in Safe Mode with Networking
|
||||
set /a REBOOT=0
|
||||
|
||||
for /f "delims=" %%G in (%FILENAME%) do (
|
||||
set SERVICE=%%G
|
||||
call :reset-errorlevel
|
||||
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\!SERVICE!" /f > nul 2>&1
|
||||
if !ERRORLEVEL! GTR 0 (
|
||||
echo ERROR: could not configure "!SERVICE!" service to start in Safe Mode with Networking
|
||||
set /a REBOOT=!REBOOT!+1
|
||||
)
|
||||
)
|
||||
|
||||
call :reset-errorlevel
|
||||
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce" /v "*RestartNormalMode" /t REG_SZ /d "%SystemRoot%\System32\bcdedit.exe /deletevalue {current} safeboot" /f > nul 2>&1
|
||||
if %ERRORLEVEL% GTR 0 (
|
||||
echo ERROR: could not configure reboot into normal mode
|
||||
set /a REBOOT=%REBOOT%+1
|
||||
)
|
||||
|
||||
if %REBOOT% EQU 0 goto :reboot
|
||||
goto :end-error
|
||||
|
||||
:reboot
|
||||
call :reset-errorlevel
|
||||
"%SystemRoot%\System32\bcdedit.exe" /set {current} safeboot network
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
shutdown /r /f /t 10
|
||||
echo Restarting in 10 seconds
|
||||
goto :end
|
||||
) else (
|
||||
echo ERROR: could not restart in Safe Mode with Networking
|
||||
goto :end-error
|
||||
)
|
||||
|
||||
:end-error
|
||||
echo.
|
||||
echo Errors were encountered and the system will not be restarted
|
||||
echo Please make sure this script is run with administrative privileges
|
||||
goto :end
|
||||
|
||||
:end
|
||||
del /f %FILENAME%
|
||||
goto :EOF
|
||||
|
||||
:reset-errorlevel
|
||||
cmd /c "exit /b 0"
|
||||
@@ -538,5 +538,49 @@ function Remove-File ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
||||
}
|
||||
}
|
||||
|
||||
# Function to ZIP a file or directory
|
||||
function Zip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
||||
If ( $(Get-Item $path) -is [System.IO.DirectoryInfo] ) {
|
||||
$dest = '{0}\{1}.zip' -f $(Split-Path -Parent $path),$(Split-Path -Leaf $path)
|
||||
LogMsg "Creating zip file of: ${path}"
|
||||
Try {
|
||||
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
||||
[IO.Compression.ZipFile]::CreateFromDirectory($path, $dest)
|
||||
}
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
If ( Test-Path $dest ) { Return $dest } Else { Return $false }
|
||||
}
|
||||
ElseIf ( $(Get-Item $path) -is [System.IO.FileInfo] ) {
|
||||
$dir = $path.Substring(0, $path.LastIndexOf('.'))
|
||||
Try {
|
||||
LogMsg "Creating directory: ${path}"
|
||||
New-Item -ItemType Directory -Path $dir -ErrorAction Stop | Out-Null
|
||||
LogMsg "Moving ""${path}"" into ""${dir}"""
|
||||
Move-Item -Path $path -Destination $dir -Force -ErrorAction Stop | Out-Null
|
||||
}
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
Zip-Object $dir
|
||||
}
|
||||
Else { LogMsg "Could not determine the file/folder status: ${path}" }
|
||||
}
|
||||
|
||||
# Function to UNZIP a file or directory
|
||||
function Unzip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) {
|
||||
$ext = [System.IO.Path]::GetExtension($path)
|
||||
If ( $ext -eq ".zip" ) {
|
||||
LogMsg "Extracting ""${path}"" to ""${dest}"""
|
||||
$dest = Split-Path -Parent $path
|
||||
Try {
|
||||
Add-Type -Assembly "System.IO.Compression.FileSystem"
|
||||
[IO.Compression.ZipFile]::ExtractToDirectory($path, $dest)
|
||||
}
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
}
|
||||
Else { LogMsg "The path specified is not a zip file: ${path}" }
|
||||
}
|
||||
|
||||
Setup-MSPDirectories
|
||||
Setup-LogFile
|
||||
Setup-LogFile
|
||||
|
||||
#Zip-Object "C:\Users\dyoder\Desktop\wifi"
|
||||
Unzip-Object "C:\Users\dyoder\Desktop\wifi.zip"
|
||||
Binary file not shown.
Reference in New Issue
Block a user