Created
May 5, 2015 22:26
-
-
Save Iristyle/e5ae9b638a6324e66909 to your computer and use it in GitHub Desktop.
Run cmd.exe / powershell.exe in an interactive service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cinst rktools.2003 | |
cd 'C:\Program Files (x86)\Windows Resource Kits\Tools' | |
$serviceName = 'Interactive SYSTEM cmd' | |
.\instsrv.exe $serviceName 'C:\Program Files (x86)\Windows Resource Kits\Tools\srvany.exe' | |
sc.exe config $serviceName depend= UI0Detect start= demand | |
$servicePath = "HKLM:\SYSTEM\CurrentControlSet\Services\$serviceName" | |
$serviceParams = New-Item $servicePath -Name Parameters | |
New-ItemProperty -Path $serviceParams.PSPath -PropertyType String -Name 'AppDirectory' -Value 'c:\windows\system32' -Force | |
New-ItemProperty -Path $serviceParams.PSPath -PropertyType String -Name 'Application' -Value 'c:\windows\system32\cmd.exe' -Force | |
$serviceConfig = Get-Item $servicePath | |
#set 9th bit, from http://www.codeproject.com/KB/install/cswindowsservicedesktop.aspx | |
$newType = $serviceConfig.GetValue('Type') -bor 0x100 | |
Set-ItemProperty -Path $serviceConfig.PSPath -Name Type -Value $newType | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cinst rktools.2003 | |
cd 'C:\Program Files (x86)\Windows Resource Kits\Tools' | |
$serviceName = 'Interactive SYSTEM Powershell' | |
.\instsrv.exe $serviceName 'C:\Program Files (x86)\Windows Resource Kits\Tools\srvany.exe' | |
# sc.exe config $serviceName depend= UI0Detect start= demand | |
sc.exe config $serviceName start= demand | |
$servicePath = "HKLM:\SYSTEM\CurrentControlSet\Services\$serviceName" | |
$serviceParams = New-Item $servicePath -Name Parameters | |
New-ItemProperty -Path $serviceParams.PSPath -PropertyType String -Name 'AppDirectory' -Value 'c:\windows\system32\WindowsPowershell\v1.0' -Force | |
New-ItemProperty -Path $serviceParams.PSPath -PropertyType String -Name 'Application' -Value 'c:\windows\system32\WindowsPowershell\v1.0\powershell.exe' -Force | |
$serviceConfig = Get-Item $servicePath | |
#set 9th bit, from http://www.codeproject.com/KB/install/cswindowsservicedesktop.aspx | |
$newType = $serviceConfig.GetValue('Type') -bor 0x100 | |
Set-ItemProperty -Path $serviceConfig.PSPath -Name Type -Value $newType |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment