-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpassword-reset-windows.userdata
29 lines (23 loc) · 2.15 KB
/
password-reset-windows.userdata
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
rem cmd
set WEB_SERVER=10.12.137.55:8181
mkdir "%PROGRAMDATA%\password-reset"
echo timeout 60 > %PROGRAMDATA%\password-reset\password-reset.cmd
echo pushd "%PROGRAMDATA%\password-reset">> %PROGRAMDATA%\password-reset\password-reset.cmd
echo "c:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python27\python" -c "import urllib; file = urllib.URLopener(); file.retrieve('http://%WEB_SERVER%/password-reset.py', 'password-reset.py')">> %PROGRAMDATA%\password-reset\password-reset.cmd
echo echo "INFO: Downloaded the latest %PROGRAMDATA%\password-reset\password-reset.py">> %PROGRAMDATA%\password-reset\password-reset.cmd
echo "c:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python27\python" "%PROGRAMDATA%\password-reset\password-reset.py">> %PROGRAMDATA%\password-reset\password-reset.cmd
echo popd>> %PROGRAMDATA%\password-reset\password-reset.cmd
:: Method 1. Enable cloudbase-init on every boot - this is the only one that works
reg delete "HKEY_LOCAL_MACHINE\Software\Cloudbase Solutions\Cloudbase-Init" /f
reg delete "HKEY_LOCAL_MACHINE\Software\Wow6432Node\Cloudbase Solutions\Cloudbase-Init" /f
::start /wait %PROGRAMDATA%\password-reset\password-reset.cmd
start %PROGRAMDATA%\password-reset\password-reset.cmd
:: Method 2. Using scheduled tasks - never executes
::schtasks /create /tn password-reset /tr %PROGRAMDATA%\password-reset\password-reset.cmd /sc onstart /ru SYSTEM /rl HIGHEST
::schtasks /create /tn password-reset /tr %PROGRAMDATA%\password-reset\password-reset.cmd /sc onstart /ru SYSTEM /rl HIGHEST /v1
:: Method 3. Add a registry key to run on startup, only works on user login
::reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "password-reset" /d "%PROGRAMDATA%\password-reset\password-reset.cmd
:: Method 4. Create a windows service, but doesn't work with batch files
::sc create password-reset binpath= "C:\Windows\System32\cmd.exe /C %PROGRAMDATA%\password-reset\password-reset.cmd" start= auto
:: Method 5. Add a GPO startup script - never executes
::reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Startup\0\0" /v "Script" /d "%PROGRAMDATA%\password-reset\password-reset.cmd