If I was doing this with action script then I would probably do it like this:
action uses wow64 redirection false
//Actions for Windows 2012 Servers
if {windows of operating system and name of operating system as lowercase contains "2012"}
//Change the File Name
if {exists file "c:\Windows\System32\GroupPolicy\Machine\Registry.pol"}
waithidden copy "c:\Windows\System32\GroupPolicy\Machine\Registry.pol" "c:\Windows\System32\GroupPolicy\Machine\Registry_pol_hold.txt"
delete "c:\Windows\System32\GroupPolicy\Machine\Registry.pol"
endif
//Verify file has been changed
continue if {exists file "c:\Windows\System32\GroupPolicy\Machine\Registry_pol_hold.txt"}
//Create Registry Key
waithidden cmd.exe /C reg add “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers” /v RegisterSpoolerRemoteRpcEndPoint /t REG_DWORD /d 0 /f
//Restart Spooler Service and Force Group Policy Update
if {exists running service "spooler"}
waithidden cmd.exe /C net stop spooler
waithidden cmd.exe /C net start spooler
waithidden cmd.exe /C gpudate /force
endif
//Actions for 2016 Servers
elseif {windows of operating system and name of operating system as lowercase contains "2016"}
//Change the File Name
if {exists file "c:\Windows\System32\GroupPolicy\Machine\Registry.pol"}
waithidden copy "c:\Windows\System32\GroupPolicy\Machine\Registry.pol" "c:\Windows\System32\GroupPolicy\Machine\Registry_pol_hold.txt"
delete "c:\Windows\System32\GroupPolicy\Machine\Registry.pol"
endif
//Verify file has been changed
continue if {exists file "c:\Windows\System32\GroupPolicy\Machine\Registry_pol_hold.txt"}
//Create Registry Keys
waithidden cmd.exe /C reg add “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers” /v DisableWebPnPDownload /t REG_DWORD /d 0 /f
waithidden cmd.exe /C reg add “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers” /v DisableHTTPPrinting /t REG_DWORD /d 0 /f
//Restart Spooler Service and Force Group Policy Update
if {exists running service "spooler"}
waithidden cmd.exe /C net stop spooler
waithidden cmd.exe /C net start spooler
waithidden cmd.exe /C gpudate /force
endif
endif
You could add in a lot more exit codes and verification’s but this is just rough and there’s someone out there who would probably simplify this too