Skip to content

Commit

Permalink
fix: minor fixes to setSvc.cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyueta committed Sep 9, 2023
1 parent 6df2f69 commit 7a6b12b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ setlocal EnableDelayedExpansion
if "%~1"=="/silent" goto main

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" "%*"
call %windir%\AtlasModules\Scripts\RunAsTI.cmd "%~f0" "%*"
exit /b
)

Expand All @@ -28,12 +28,10 @@ for %%a in (
"Microsoft_Bluetooth_AvrcpTransport"
"RFCOMM"
) do (
rem A full path is required for AME Wizard configuration as of now
call %windir%\AtlasModules\Scripts\setSvc.cmd %%~a 4
)

:: Disable Bluetooth devices
:: A full path is required for AME Wizard configuration as of now
call %windir%\AtlasModules\Scripts\toggleDev.cmd -Silent '*Bluetooth*'

attrib +h "!appdata!\Microsoft\Windows\SendTo\Bluetooth File Transfer.LNK"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ foreach ($interface in $interfaces) {
Set-ItemProperty -Path $interface.PSPath -Name "NetbiosOptions" -Value 2 | Out-Null
}

# Disable Net Bios service
cmd /c "call setSvc.cmd NetBT 4"

# Set network profile to 'Public Network'
$profiles = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles" -Recurse | Where-Object { $_.GetValue("Category") -ne $null }
foreach ($profile in $profiles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ foreach ($interface in $interfaces) {
Set-ItemProperty -Path $interface.PSPath -Name "NetbiosOptions" -Value 2 | Out-Null
}

# Enable Net Bios service
cmd /c "call setSvc.cmd NetBT 1"

choice /c:yn /n /m "Would you like to change your network profile to 'Private'? [Y/N] "
if ($LASTEXITCODE -eq 1) {
# Set network profile to 'Private Network'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ setlocal EnableDelayedExpansion
if "%~1"=="/setup" goto main

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" "%*"
call %windir%\AtlasModules\Scripts\RunAsTI.cmd "%~f0" "%*"
exit /b
)

Expand Down Expand Up @@ -76,7 +76,6 @@ powercfg /setacvalueindex scheme_current 7516b95f-f776-4464-8c53-06167f40cc99 3c
powercfg /setactive scheme_current

:: Disable Advanced Configuration and Power Interface (ACPI) devices
:: A full path is required for AME Wizard configuration as of now
call %windir%\AtlasModules\Scripts\toggleDev.cmd @("ACPI Processor Aggregator", "Microsoft Windows Management Interface for ACPI") > nul

:: Disable driver/device power saving
Expand Down
17 changes: 8 additions & 9 deletions src/playbook/Executables/AtlasModules/Scripts/setSvc.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" "%*"
exit /b
)

goto script

----------------------------------------
Expand All @@ -24,17 +23,17 @@ call setSvc.cmd [service] [start]
----------------------------------------

:script
if [%~1]==[] echo You need to run this with a service/driver to disable.
if [%~2]==[] echo You need to run this with an argument ^(0-4^) to configure the service's startup.
if %~2 LSS 0 echo Invalid start value ^(%~2^) for %~1.
if %~2 GTR 4 echo Invalid start value ^(%~2^) for %~1.
if [%~1] == [] echo error: you need to run this with a service/driver to disable. & exit /b 1
if [%~2] == [] echo error: you need to run this with an argument ^(0-4^) to configure the service's startup. & exit /b 1
if %~2 LSS 0 echo error: invalid start value ^(%~2^) for %~1. & exit /b 1
if %~2 GTR 4 echo error: invalid start value ^(%~2^) for %~1. & exit /b 1

reg query "HKLM\SYSTEM\CurrentControlSet\Services\%~1" > nul 2>&1 || (
echo The specified service/driver ^(%~1^) was not found.
echo error: the specified service/driver ^(%~1^) was not found.
exit /b 1
)

reg add "HKLM\SYSTEM\CurrentControlSet\Services\%~1" /v "Start" /t REG_DWORD /d "%~2" /f > nul 2>&1 || (
echo Failed to set service %~1 with start value %~2^^! Unknown error.
reg add "HKLM\SYSTEM\CurrentControlSet\Services\%~1" /v "Start" /t REG_DWORD /d "%~2" /f > nul || (
echo error: failed to set service %~1 with start value %~2^^! Unknown error.
exit /b 1
)
)

0 comments on commit 7a6b12b

Please sign in to comment.