powershell script
Set-ExecutionPolicy Unrestricted
## NEEDED FOR IIS CMDLETS
Import-Module WebAdministration
## CREATE FTP SITE AND SET C:\inetpub\ftproot AS HOME DIRECTORY
New-WebFtpSite -Name "test" -Port "21" -Force
cmd /c \Windows\System32\inetsrv\appcmd set SITE "test" "-virtualDirectoryDefaults.physicalPath:C:\inetpub\ftproot"
## SET PERMISSIONS
## Allow SSL connections
Set-ItemProperty "IIS:\Sites\test" -Name ftpServer.security.ssl.controlChannelPolicy -Value 0
Set-ItemProperty "IIS:\Sites\test" -Name ftpServer.security.ssl.dataChannelPolicy -Value 0
## Enable Basic Authentication
Set-ItemProperty "IIS:\Sites\test" -Name ftpServer.security.authentication.basicAuthentication.enabled -Value $true
## Set USer Isolation
Set-ItemProperty "IIS:\Sites\test" -Name ftpserver.userisolation.mode -Value 3
#Set-ItemProperty "IIS:\Sites\test" -Name ftpServer.security.userIsolation. -Value $true
## Give Authorization to Administrators and grant "read"/"write" privileges
Add-WebConfiguration "/system.ftpServer/security/authorization" -value @{accessType="Allow";roles="";permissions="Read,Write";users="*"} -PSPath IIS:\ -location "test"
## Give Authorization to All Users
#appcmd set config %ftpsite% /section:system.ftpserver/security/authorization /+[accessType='Allow',permissions='Read,Write',roles='',users='*'] /commit:apphost
## Restart the FTP site for all changes to take effect
Restart-WebItem "IIS:\Sites\test"
that I want to run it with lua
I make that script
function Create_iis()
tl1="Set-ExecutionPolicy Unrestricted"
tl2="Import-Module WebAdministration"
tl3="New-WebFtpSite -Name \"test\" -Port \"21\" -Force"
tl4="cmd \/c \\Windows\\System32\\inetsrv\\appcmd set SITE \"test\" \"-virtualDirectoryDefaults.physicalPath:C:\\inetpub\\ftproot\""
tl5="Set-ItemProperty \"IIS:\\Sites\\test\" -Name ftpServer.security.ssl.controlChannelPolicy -Value 0"
tl6="Set-ItemProperty \"IIS:\\Sites\\test\" -Name ftpServer.security.ssl.dataChannelPolicy -Value 0"
tl7="Set-ItemProperty \"IIS:\\Sites\\test\" -Name ftpServer.security.authentication.basicAuthentication.enabled -Value $true"
tl8="Set-ItemProperty \"IIS:\\Sites\\test\" -Name ftpserver.userisolation.mode -Value 3"
tl9="Add-WebConfiguration \"\/system.ftpServer\/security\/authorization\" -value \@\{accessType=\"Allow\";roles=\"\";permissions=\"Read\,Write\";users=\"*\"} -PSPath IIS:\ -location \"test\""
tl10="Restart-WebItem \"IIS:\\Sites\\test\""
file = io.open("c:\\testiis.ps1","w");
file:write(tl1.."\n"..tl2.."\n"..tl3.."\n"..tl4.."\n"..tl5.."\n"..tl6.."\n"..tl7.."\n"..tl8.."\n"..tl9.."\n"..tl10.."\n"..);
file:close("c:\\testiis.ps1");
result = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe", "open", "c:\\testiis.ps1", "", SW_HIDE,true);
if result ~=0 then
Dialog.Message("Error", "Error ", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
end
end
and work well
but I need to check for every line in this script if return error then exit and give me the line that make the error
so I make stupid script that
function Create_iis()
result1 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","Set-ExecutionPolicy Unrestricted")
result2 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","Import-Module WebAdministration")
result3 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","New-WebFtpSite -Name \"test\" -Port \"21\" -Force" )
result4 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","cmd \/c \\Windows\\System32\\inetsrv\\appcmd set SITE \"test\" \"-virtualDirectoryDefaults.physicalPath:C:\\inetpub\\ftproot\"")
result5 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","Set-ItemProperty \"IIS:\\Sites\\test\" -Name ftpServer.security.ssl.controlChannelPolicy -Value 0")
result6 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","Set-ItemProperty \"IIS:\\Sites\\test\" -Name ftpServer.security.ssl.dataChannelPolicy -Value 0")
result7 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","Set-ItemProperty \"IIS:\\Sites\\test\" -Name ftpServer.security.authentication.basicAuthentication.enabled -Value $true")
result8 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","Set-ItemProperty \"IIS:\\Sites\\test\" -Name ftpserver.userisolation.mode -Value 3")
result9 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","Add-WebConfiguration \"\/system.ftpServer\/security\/authorization\" -value \@\{accessType=\"Allow\";roles=\"\";permissions=\"Read\,Write\";users=\"*\"} -PSPath IIS:\ -location \"test\"" )
result10 = Shell.Execute("C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe","open","Restart-WebItem \"IIS:\\Sites\\test\"")
end
and check for every result
but there are some commands that depend on each so it make error
it is impossible to make that ?
sorry for poor English
Thanks in advance