Jump to content

Writing a SetupComplete Batch file


UpGrade

Recommended Posts

Hi guys,

I have recently written a batch file for disabling telemetry on windows and want to use it as a setupcomplete.cmd i have tested and it works fine but then when i put it into the %OEM%\Scripts folder it does not run on system install.

can anyone that is good with this kind of stuff please take a look! i can send the file to you if you pm me

Link to comment
Share on other sites


  • Replies 36
  • Views 4.1k
  • Created
  • Last Reply

post batch file so people can have a look

Script complete with the files it uses is here:

Password:

He110

The script uses:

Destroy Windows 10 Spying

Spybot Anti-Beacon for Windows 10 v1.2.0.19

Disable Windows 7/8/8.1 Telemetry (+Bonus Services) v0.2.8

O&O ShutUp10 v1.0.1345

Disable Windows 10 Tracking

The script calls on these other programs to disable the telemetry and then sets scheduled tasks to run once each startup and logon to run a script that disables telemetry incase windows installs updates automatically!

i didnt code any of the files only the SetupComplete.cmd and Invisible.vbs

The script works completely fine if you run it but when integrated into iso it does not the install just hangs and you have to reboot then when you do script never runs i cant work out why as it works perfectly if run

Link to comment
Share on other sites


Just off the top of my head without looking at your scripts, have you tried copying the files to the drive during the install and then calling them from a temp directory which could be cleaned up after it has finished running? I have run into similar problems in the past and this was an easy fix for me.

Link to comment
Share on other sites


Just off the top of my head without looking at your scripts, have you tried copying the files to the drive during the install and then calling them from a temp directory which could be cleaned up after it has finished running? I have run into similar problems in the past and this was an easy fix for me.

I was going to try copying them to the harddrive and running but i wanted to post here first incase anyone knows another way or the reason it wont work like this

Link to comment
Share on other sites


Post the batch, im not the sort of person with limited data who's going to download a 32mb file full of programs to look at a simple batch

Just off the top of my head, check your placement path, the batch needs to be in:

Sources\$OEM$\$$\Setup\Scripts

If i could see the batch i could see if any of it has an issue....

Link to comment
Share on other sites


Post the batch, im not the sort of person with limited data who's going to download a 32mb file full of programs to look at a simple batch

Just off the top of my head, check your placement path, the batch needs to be in:

Sources\$OEM$\$$\Setup\Scripts

If i could see the batch i could see if any of it has an issue....

@ECHO OFFCOLOR 0ASET V=1.0TITLE Windows Telemetry and Data Collection DisablerECHO #########################################################ECHO #                                                       #ECHO #  WINDOWS 10 Enterprise LTSB Build 10240 X64           #ECHO #  Script Version %V%                                   #ECHO #                                                       #ECHO #########################################################:REGISTRY TWEAKSREGEDIT /s DarkTheme.regREGEDIT /s TakeOwnership.reg:TELEMETRY SCHEDULED TASK@ECHO OFFXCOPY "DWT" "%SYSTEMROOT%\DWT\" /E /H /S /KSCHTASKS /Create /RU "SYSTEM" /SC ONSTART /TN DisableMicrosoftSpying-Telemetry-1 /TR "'%SYSTEMROOT%\DWT\Invisible.vbs'"SCHTASKS /Create /RU "SYSTEM" /SC ONLOGON /TN DisableMicrosoftSpying-Telemetry-2 /TR "'%SYSTEMROOT%\DWT\Invisible.vbs'":TELEMETRY@ECHO OFFECHO Initialising The Removal of TelemetryECHO ....................../´¯/) ECHO ....................,/¯../ ECHO .................../..../ ECHO ............./´¯/'...'/´¯¯`·¸ ECHO ........../'/.../..../......./¨¯\ ECHO ........('(...´...´.... ¯~/'...') ECHO .........\.................'...../ ECHO ..........''...\.......... _.·´ ECHO ............\..............( ECHO ..............\.............\...ECHO **************************************************************ECHO WARNING:                                                     *ECHO BE CAREFULL IF YOU WANT WINDOWS UPDATES DO NOT DISABLE THEM!!*ECHO **************************************************************TIMEOUT 5                                                         ECHO **************************************************************ECHO 1. Now Running: Destroy Windows Spying                       *ECHO    Please Select Options Throughout all Tabs Then            *ECHO    Press the Button                                          *ECHO **************************************************************START /WAIT DWS.exe                                               ECHO **************************************************************ECHO 2. Now Running: Disable Windows 10 Tracking                  *ECHO    Please Select Options Then                                *ECHO    Press the Get privacy! Button                             *ECHO **************************************************************START /WAIT DWT.exe                                               ECHO **************************************************************ECHO 3. Now Running: OandO ShutUp10                               *ECHO    Please Use the Sliders to Turn Options On or Off          *ECHO **************************************************************START /WAIT OOS.exe                                               ECHO **************************************************************ECHO 4. Now Running: Spybot Anti-Beacon                           *ECHO    Please Select Options Throughout all Tabs Then            *ECHO    Apply Immunizations                                       *ECHO **************************************************************START /WAIT SBAB.exe                                              ECHO **************************************************************ECHO WINDOWS TELEMETRY REMOVAL COMPLETE.                          *ECHO **************************************************************TIMEOUT 5CLS:START MENU INSTALLERTITLE Start Menu InstallerCOLOR 70ECHO #########################################################ECHO #                                                       #ECHO #                Start Menu Installer                   #ECHO #                                                       #ECHO #                                                       #ECHO #########################################################ECHOECHO                    **************************************ECHO                    *   1) StartIsBack++                 *ECHO                    *                                    *ECHO                    *   2) Start10                       *ECHO                    *                                    *ECHO                    *   3) ClassicShell                  *ECHO                    *                                    *ECHO                    *   4) NONE (Use Windows 10 Default) *ECHO                    **************************************ECHO Select an Option and Press Enter...  set/p "cho=>" if %cho%==1 goto StartIsBackif %cho%==2 goto Start10if %cho%==3 goto ClassicShellif %cho%==4 goto Activationcls:StartIsBack++ECHO Please Use the StartIsBack++ Installer...start /WAIT SIB.exegoto Activation:Start10ECHO Please Use the Start10 Installer...start /WAIT S10.exegoto Activation:ClassicShellECHO Please Use the ClassicShell Installer...start /WAIT CS.exegoto Activation:ACTIVATIONTITLE ActivationCOLOR 1FECHO Starting Windows Activation.TIMEOUT 2CLSECHO ACTIVATING WINDOWSECHO **********************************ECHO * Runing Activation Procedure... *ECHO * Windows May Reboot.            *ECHO **********************************pushd "%~dp0"start /wait KMSpico_setup.exe /verysilent /noiconsregedit /s RunOnce.regtimeout /t 120shutdown -r -t 0popdexit 

Link to comment
Share on other sites


knowledge-Spammer

its a nice bit of code u did

i tested this script its fine

i see u say this

The script works completely fine if you run it but when integrated into iso it does not the install just hangs and you have to reboot then when you do script never runs i cant work out why as it works perfectly if run

have u tryed to edit the script i say this as when tested i did get something about

line 5 ?

Link to comment
Share on other sites


knowledge-Spammer

i think its going to take more people to help and test comeon guys plz test and try and help

Link to comment
Share on other sites


Hi UpGrade:

I love make scripting ^_^

..I check your script, is very well done. The reason didn't work is one:

the script will always run as administrator, so its working directory is always c:\windows\system32

to correct the script you must insert this code if the exe is into the same directory of the script

%~dp0\
in a nutshell take as example this code of your:

START /WAIT DWS.exe
will be modify into this:

START /WAIT %~dp0\DWS.exe
same thing will be apply to reg import ;)

hope this help and improve your scripting skills

Link to comment
Share on other sites


its a nice bit of code u did

i tested this script its fine

i see u say this

The script works completely fine if you run it but when integrated into iso it does not the install just hangs and you have to reboot then when you do script never runs i cant work out why as it works perfectly if run

have u tryed to edit the script i say this as when tested i did get something about

line 5 ?

Thanks for helping! i edited the script so many times changing it to copy files so SYSTEMROOT and then run from there i tried so many things but nothing works!

think i changed the script about 6 times and tried different things!

Hi UpGrade:

I love make scripting ^_^

..I check your script, is very well done. The reason didn't work is one:

the script will always run as administrator, so its working directory is always c:\windows\system32

to correct the script you must insert this code if the exe is into the same directory of the script

%~dp0\
in a nutshell take as example this code of your:

START /WAIT DWS.exe
will be modify into this:

START /WAIT %~dp0\DWS.exe
same thing will be apply to reg import ;)

hope this help and improve your scripting skills

Thanks it was my first script! Thanks so much for your help i understand the part about %~dp0 but how do i make the working directory c:\windows\system32 ? do i have to make the script copy files there and run another script or just copy files there and run ?

Link to comment
Share on other sites


Hi UpGrade:

if you understand the %~dp0 then I may know that it refear to path and drive letter itself, so don't need to copy to anywhere your program.

however if you want and if you prefer to made a clear and specified path of your scripts, no problem ..remember to specify the real and only one right path

;)

Link to comment
Share on other sites


Hi UpGrade:

if you understand the %~dp0 then I may know that it refear to path and drive letter itself, so don't need to copy to anywhere your program.

however if you want and if you prefer to made a clear and specified path of your scripts, no problem ..remember to specify the real and only one right path

;)

yeah i get that the dp is drive path but the path to the setupcomplete.cmd is on the iso on the root of the iso then sources\$OEM$\$$\Setup\Scripts\SetupComplete.cmd

so im confused as to how to make it run as c:\windows\system32 unless %~dp0 is what makes it to run in c:\windows\system32 ?

i have changed every exe to

START /WAIT %~dp0\DWS.exeSTART /WAIT %~dp0\DWT.exe

and so on

and the registry like this#

REGEDIT /s %~dp0\DarkTheme.regREGEDIT /s %~dp0\TakeOwnership.reg

but now when put into the iso the screen just stays black after setup any ideas ?

maby if i put

pushd "%~dp0"

at the start of the script ?

Link to comment
Share on other sites


yes my friend,

%~dp0 substitute the entire path where the SetupComplete.cmd is. so it's very strange that don't work

mmmm... when something wrong, I disable first echo off to test and view where the script hangs...

try to remark 'echo off' too and test where is blocking and if appear some errore message

Link to comment
Share on other sites


yes my friend,

%~dp0 substitute the entire path where the SetupComplete.cmd is. so it's very strange that don't work

mmmm... when something wrong, I disable first echo off to test and view where the script hangs...

try to remark 'echo off' too and test where is blocking and if appear some errore message

well i would try that but i cant even see the batch the screen gets stuck here:

Untitled.png

Would you edit the code as you would do it please? then i can compare to the changes i have made and see if i did something wrong

Link to comment
Share on other sites


@UpGrade:

you made changes well, like I will made. I'm sorry for not working and not see some error message -__-"

this is a script well done and working:

@echo off

cd %~dp0

start /wait %~dp0\Fixes\Features.cmd >nul

start /wait %~dp0\Apps\ClassicShellSetup64.msi /qn

start /wait %windir%\Setup\scripts\Apps\vmware\setup64.exe /S /v"/qn REBOOT=R ADDLOCAL=ALL

start /wait %windir%\Setup\scripts\Apps\directx_Jun2010_redist\DXSETUP.EXE /silent

schtasks.exe /change /tn "\Microsoft\Windows\Server Manager\ServerManager" /disable

copy Fixes.cmd "%programdata%\Microsoft\Windows\Start Menu\Programs\StartUp\Fixes.cmd"

sc config AudioSrv start= auto

sc config AudioEndpointBuilder start= auto

sc config Themes start= auto

reg import %~dp0\Reg\srv2012_regs.reg

reg import %~dp0\Reg\aero_mouse_pointers.reg

reg import %~dp0\Reg\add_take_ownership.reg

rem reg import %~dp0\Reg\replace_task_manager.reg

rem reg import %~dp0\Reg\disable_uac.reg

shutdown -r -t 10

exit

the only thing I might have missed is the change directory command at first line :P

cd %~dp0
..maybe this can be useful for your script and hope don't hangs anymore

:)

Link to comment
Share on other sites


knowledge-Spammer

may be can help may need editing

:: ### Admin Check..
if "%~1"=="a" goto :start
:getfile
set "file=%temp%\%random%.file.vbs"
if exist "%file%" goto :getfile
>"%file%" echo Set UAC = CreateObject("Shell.Application")
>>"%file%" echo UAC.ShellExecute "%~f0", "a", "", "runas", 1
start "" "%file%"
goto :eof
@ECHO OFF
COLOR 0A
SET V=1.0
TITLE Windows Telemetry and Data Collection Disabler
ECHO #########################################################
ECHO # #
ECHO # WINDOWS 10 Enterprise LTSB Build 10240 X64 #
ECHO # Script Version %V% #
ECHO # #
ECHO #########################################################

:REGISTRY TWEAKS
REGEDIT /s DarkTheme.reg
REGEDIT /s TakeOwnership.reg

:TELEMETRY SCHEDULED TASK
@ECHO OFF
XCOPY "DWT" "%SYSTEMROOT%\DWT\" /E /H /S /K
SCHTASKS /Create /RU "SYSTEM" /SC ONSTART /TN DisableMicrosoftSpying-Telemetry-1 /TR "'%SYSTEMROOT%\DWT\Invisible.vbs'"
SCHTASKS /Create /RU "SYSTEM" /SC ONLOGON /TN DisableMicrosoftSpying-Telemetry-2 /TR "'%SYSTEMROOT%\DWT\Invisible.vbs'"

:TELEMETRY
@ECHO OFF
ECHO Initialising The Removal of Telemetry
ECHO ....................../´¯/)
ECHO ....................,/¯../
ECHO .................../..../
ECHO ............./´¯/'...'/´¯¯`·¸
ECHO ........../'/.../..../......./¨¯\
ECHO ........('(...´...´.... ¯~/'...')
ECHO .........\.................'...../
ECHO ..........''...\.......... _.·´
ECHO ............\..............(
ECHO ..............\.............\...
ECHO **************************************************************
ECHO WARNING: *
ECHO BE CAREFULL IF YOU WANT WINDOWS UPDATES DO NOT DISABLE THEM!!*
ECHO **************************************************************
TIMEOUT 5
ECHO **************************************************************
ECHO 1. Now Running: Destroy Windows Spying *
ECHO Please Select Options Throughout all Tabs Then *
ECHO Press the Button *
ECHO **************************************************************
START /WAIT DWS.exe
ECHO **************************************************************
ECHO 2. Now Running: Disable Windows 10 Tracking *
ECHO Please Select Options Then *
ECHO Press the Get privacy! Button *
ECHO **************************************************************
START /WAIT DWT.exe
ECHO **************************************************************
ECHO 3. Now Running: OandO ShutUp10 *
ECHO Please Use the Sliders to Turn Options On or Off *
ECHO **************************************************************
START /WAIT OOS.exe
ECHO **************************************************************
ECHO 4. Now Running: Spybot Anti-Beacon *
ECHO Please Select Options Throughout all Tabs Then *
ECHO Apply Immunizations *
ECHO **************************************************************
START /WAIT SBAB.exe
ECHO **************************************************************
ECHO WINDOWS TELEMETRY REMOVAL COMPLETE. *
ECHO **************************************************************
TIMEOUT 5
CLS

:START MENU INSTALLER
TITLE Start Menu Installer
COLOR 70
ECHO #########################################################
ECHO # #
ECHO # Start Menu Installer #
ECHO # #
ECHO # #
ECHO #########################################################
ECHO
ECHO **************************************
ECHO * 1) StartIsBack++ *
ECHO * *
ECHO * 2) Start10 *
ECHO * *
ECHO * 3) ClassicShell *
ECHO * *
ECHO * 4) NONE (Use Windows 10 Default) *
ECHO **************************************

ECHO Select an Option and Press Enter...
set/p "cho=>"
if %cho%==1 goto StartIsBack
if %cho%==2 goto Start10
if %cho%==3 goto ClassicShell
if %cho%==4 goto Activation
cls

:StartIsBack++
ECHO Please Use the StartIsBack++ Installer...
start /WAIT SIB.exe
goto Activation

:Start10
ECHO Please Use the Start10 Installer...
start /WAIT S10.exe
goto Activation

:ClassicShell
ECHO Please Use the ClassicShell Installer...
start /WAIT CS.exe
goto Activation

:ACTIVATION
TITLE Activation
COLOR 1F
ECHO Starting Windows Activation.
TIMEOUT 2
CLS
ECHO ACTIVATING WINDOWS
ECHO **********************************
ECHO * Runing Activation Procedure... *
ECHO * Windows May Reboot. *
ECHO **********************************
pushd "%~dp0"
start /wait KMSpico_setup.exe /verysilent /noicons
regedit /s RunOnce.reg
timeout /t 120
shutdown -r -t 0
popd
exit

Link to comment
Share on other sites


Let me get this straight...little confused but you are wanting setupcomplete.cmd to run files in the windir/system32 folder, correct? The set path as variable then call instead of start /wait because that doesnt work with all exe's. Like this...

SET PATHA="%windir%\system32"

CALL %PATHA%\DWS.exe

CALL %PATHA%\DWT.exe

Calls are better because it wont continue until exit code. The %~dp0 is used for path if exe's are located in same directory as the setupcomplete.cmd file (scripts folder). In this case you would use like this...

cd /d "%~dp0"

CALL DWS.exe

CALL DWT.exe

Also if needing timeout you can nul it out so it doesnt show if you wish...

Timeout /t 120 >nul

Link to comment
Share on other sites


cd %~dp0
..maybe this can be useful for your script and hope don't hangs anymore

:)

I will test this after works haha, thanks again just wondering can pushd "%~dp0" be used insted of cd cd %~dp0 ?

may be can help may need editing

:: ### Admin Check..

if "%~1"=="a" goto :start

:getfile

set "file=%temp%\%random%.file.vbs"

if exist "%file%" goto :getfile

>"%file%" echo Set UAC = CreateObject("Shell.Application")

>>"%file%" echo UAC.ShellExecute "%~f0", "a", "", "runas", 1

start "" "%file%"

goto :eof

Thanks for all your input guys i will test after work today and im off tomorrow so will be testing too i will report the results later!

Let me get this straight...little confused but you are wanting setupcomplete.cmd to run files in the windir/system32 folder, correct? The set path as variable then call instead of start /wait because that doesnt work with all exe's. Like this...

SET PATHA="%windir%\system32"

CALL %PATHA%\DWS.exe

CALL %PATHA%\DWT.exe

Calls are better because it wont continue until exit code. The %~dp0 is used for path if exe's are located in same directory as the setupcomplete.cmd file (scripts folder). In this case you would use like this...

cd /d "%~dp0"

CALL DWS.exe

CALL DWT.exe

Also if needing timeout you can nul it out so it doesnt show if you wish...

Timeout /t 120 >nul

Well the files that run from windir/system32 are for use a a scheduled task every startup there 2 different telemetry disabling scripts, so i made a.vbs to run them silently on logon and startup them 3 files are the only ones that get copied into that folder the other exe's should be ran from disk/iso as a one time procedure before windows boots for the first time, the script runs fine if i open normally but never when i test in a vm! i didnt try using cd /d "%~dp0" yet so im going to try after work and ill change wait to call and see if it works! thanks for you help i will post here once tested (and hopefully working)

Link to comment
Share on other sites


knowledge-Spammer

or try with somethink like this

@echo Off
set USERPROFILE=%CD%\Data
set Appdata=%CD%\Data\Appdata

start "" "%CD%\

Link to comment
Share on other sites


You need to assign drive letter to dvd or usb first in order to run from iso because %cd% doesnt have assigned drive letter yet. ;) If you are wanting to run from dvd rom or usb that is instead of copying over files.

Link to comment
Share on other sites


I have tried a few of the suggested ways tonight and none have worked setup hangs every time! will test ways i didnt tonight, tomorrow.

maby im putting the comand in wrong place or something i just dont know im so tired need sleep from it for now its driving me crazy lol

Link to comment
Share on other sites


or try with somethink like this

@echo Off

set USERPROFILE=%CD%\Data

set Appdata=%CD%\Data\Appdata

start "" "%CD%\

You need to assign drive letter to dvd or usb first in order to run from iso because %cd% doesnt have assigned drive letter yet. ;) If you are wanting to run from dvd rom or usb that is instead of copying over files.

cd %~dp0
..maybe this can be useful for your script and hope don't hangs anymore

:)

I modified the script run a reg key to disable UAC as the first command it runs then I managed to get the script to run sort of it left a file that gets created when you run Destroy windows spying (DWS.txt)

C:\Windows\Setup\scripts

and also UAC was turned off in control panel but it never displayed the cmd windows windows just logged on so the whole script didnt run through im seriously sooooooo confused as to why anyone got any ideas ?

I modifeid setupcomplete so its only:

@ECHO OFFpushd "%~dp0"START run.cmdpopdexit

run.cmd it the batch with all the code in its in same directory, just noticed when you have the $OEM$\Scripts folder everything gets copied automatically to C:\Windows\Setup\scripts

so no need to copy any files there

Link to comment
Share on other sites


You can copy the files anywhere in windows basically if you setup the oem folder correctly. Send me your work in pm and I will troubleshoot it. I have good luck with scripting so let me take a bang at it. lol I see some things that could cause it to break but without seeing the whole structure and cmd files, I am shooting in the dark.

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...