Tired of doing repetitive task... I need a script!

it’s shapping up nicely so far.
Kinda stuck at trying to change Quick Access’ options

2 Likes

tried to do a before and after comparison of the registry, is someone can understand more than i did, be my guest
regEdit folder options 3x64.txt (67.7 KB) regEdit folder options 2x64.txt (32.3 KB) regEdit folder optionsx64.txt (47.8 KB)

echo "SRVHMI01 setup script"

echo "rename ethernet adapters"
Rename-NetAdapter -Name "LAN [X1 P1]" -NewName "LAN1-PLC"
Rename-NetAdapter -Name "LAN [X2 P1]" -NewName "LAN2-HMI"
Rename-NetAdapter -Name "LAN [X3 P1]" -NewName "LAN3-DEV"
Rename-NetAdapter -Name "Slot 1 (PCIe x4)" -NewName "LAN4-EXT"

echo "Remove partition D and resize C"
Remove-Partition -DriveLetter D
Resize-Partition -DriveLetter C -size 511702277632

echo "enable remote assistance and full remote control"
reg add "hklm\system\currentcontrolset\control\remote assistance" /v fAllowToGetHelp /t REG_DWORD /d 1 /f
reg add "hklm\system\currentcontrolset\control\remote assistance" /v fAllowFullControl /t REG_DWORD /d 1 /f
netsh advfirewall firewall set rule group="remote assistance" new enable=Yes

echo "enable File and printer sharing on any network"
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
netsh advfirewall firewall set rule group="network discovery" new enable=Yes
reg add "hklm\system\currentcontrolset\control\Lsa\MSV1_0" /v NtlmMinClientSec /t REG_DWORD /d 0 /f
reg add "hklm\system\currentcontrolset\control\Lsa\MSV1_0" /v NtlmMinServerSec /t REG_DWORD /d 0 /f

echo "add exchange network drive"
net use X \\nas01\exchange /persistent:yes

echo "replace hosts file"
$ScriptPath = (Get-Item -Path ".\" -Verbose).FullName
Copy-Item -Path ($ScriptPath + "\hosts") -Destination "C:\Windows\System32\drivers\etc\hosts"

echo "paste Macrium XML configuration"
$ScriptPath = (Get-Item -Path ".\" -Verbose).FullName
Copy-Item -Path ($ScriptPath + "\Complete system backup.xml") -Destination "C:\Users\admin\Documents\Reflect\Complete system backup.xml"

echo "enable set time and time zone automatically"
reg add "hklm\system\currentcontrolset\services\w32time\parameters" /v Type /t REG_SZ /d NTP /f
reg add "hklm\system\currentcontrolset\services\tzautoupdate" /v Start /t REG_DWORD /d 3 /f

echo "change NTP server with NAS"
reg add "hklm\system\currentcontrolset\services\w32time\parameters" /v NtpServer /t REG_SZ /d 192.168.1.241 /f

echo "enable remote shutdown"
reg add "hklm\software\microsoft\windows\currentversion\policies\system" /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f

echo "install common programs"
$ScriptPath = (Get-Item -Path ".\" -Verbose).FullName
Start-Proccess ($ScriptPath + "\programs\7z1604-x64.exe") -ArgumentList /silent -Wait -NoNewWindow
Start-Proccess ($ScriptPath + "\programs\74.0.3729.108_chrome_installer.exe") -ArgumentList /silent -Wait -NoNewWindow
Start-Proccess ($ScriptPath + "\programs\DesignerLauncherSetup.exe") -ArgumentList /silent -Wait -NoNewWindow
Start-Proccess ($ScriptPath + "\programs\VisionClientLauncherSetup.exe") -ArgumentList /silent -Wait -NoNewWindow
Start-Proccess ($ScriptPath + "\programs\npp.7.7.1.Installer.x64.exe") -ArgumentList /silent -Wait -NoNewWindow
Start-Proccess ($ScriptPath + "\programs\SSMS-Setup-ENU.exe") -ArgumentList /silent -Wait -NoNewWindow
Start-Proccess ($ScriptPath + "\programs\v7.2.4557_reflect_setup_free_x64.exe")

echo "rename computer to SRVHMI01 and restart"
Rename-Computer -Restart SRVHMI01

The result of today’s constant experimentations
Things still missing:

  • quick access privacy settings and clear in file explorer
  • run a program that can only happen after rebooting the system to apply the name change
  • pinning programs to the taskbar

But man, watching it do everything in less than 5 minutes on the second server… i almost came

1 Like

It is possible to install macrium reflect silently. It’s actually broken, but I reverse engineered it and figured out a fix.

Story:
https://naoh.host/chocolatey/macrium-reflect-broken/

I’m not sure what this is. Missing punctuation?

I haven’t really found a great way around this. But rebooting then running the next script is not too hard compared to doing everything manually.

One option is to create a scheduled task to run once at the next login.

https://gallery.technet.microsoft.com/scriptcenter/b66434f1-4b3f-4a94-8dc3-e406eb30b750

image
the privacy setting of the quick access section you have in file explorer on Windows 10

yeah it’s kinda the only hard part, but not really an issue since i can always just do bit manually since it’s just one thing to do after rebooting. Was reading about it here:


but felt overwhelmed by the amount of information

Awesome! will try the pin script tomorrow, also the silent install of Macrium

Ah.

In
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer

DWORDs called ShowFrequent and ShowRecent, 1 to enable, 0 to disable.

Forgot to mention, the important part is that the silent arguments are
/qn /norestart TRANSFORMS="file.mst", where the file.mst the the MSI transform. I have it on github here, or you can create it yourself in probably two minutes if you are familiar with Orca or another MSI modification tool.

If you don’t find another way you could split the script in 2. At the end of the first one, you could link the second script to the autostart startmenu folder, then restart. The second script would then run after boot. Check if the name actually changed, then execute the rest. At the end of the second script you remove the link in the autostart. Should work?

Those are probably registry entries, but I never looked for that.

edit: should have scrolled further -_-