Seems that Powershell is the way to go forward as it is well supported with Windows 7 and Microsoft. It is a powerful script. I think it will revolutionize the way we script today.
I just wrote my first powershell script and thought it would be good to share with all. I am not going to give any tutorial for Powershell as there are a lot of them available.
There are a few things which are worth noting in this script:
1) You can get the script directory from the below script in Get-ScriptDirectory function.
2) You can suppress the remote exe installation prompt by command: $env:SEE_MASK_NOZONECHECKS = 1
code
Remove-Item env:\SEE_MASK_NOZONECHECKS
3) Installation of setup.exe with parameters can be seen in function InstallPackage
4) Permissions can be set in Powershell script using the GivePermissions function below.
Here is the code:
------------------------------------------------------
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
$env:SEE_MASK_NOZONECHECKS = 1
$val1 = Get-ScriptDirectory
$CurrentPath = $val1.ToString()
$Setup = $CurrentPath + "\setup.exe"
$Config = " "
function InstallPackage
{
# Write-host $Setup
# Write-host $Config
$process = [Diagnostics.Process]::Start($Setup,$Config)
$process.WaitForExit()
}
function GivePermissions
{
$acl = Get-Acl "C:\Program Files\PLSQL"
$acl.SetAccessRuleProtection($True, $True)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Users","Modify", "ContainerInherit, ObjectInherit", "None", "Allow")
$acl.AddAccessRule($rule)
Set-Acl "C:\Program Files\PLSQL" $acl
}
# -Main ----------------------------------
InstallPackage
GivePermissions
Remove-Item env:\SEE_MASK_NOZONECHECKS
This Blog is for all people working or related to the MSI and App-V. There are lots of issues we face in everyday work regarding the technology. The sole purpose of my blog is to help others with whatever I learn. All you people out there, please help by commenting, voting, propagating and sharing my blog with your friends and colleagues but with due credit and acknowledgement to the material posted here with my name and blog url as I still do hold the copyright of the posts here.
Showing posts with label SEE_MASK_NOZONECHECKS. Show all posts
Showing posts with label SEE_MASK_NOZONECHECKS. Show all posts
Wednesday, January 11, 2012
Thursday, August 11, 2011
Installing executable from remote location by suppressing the Open File Prompt
Many times while running a script/application exe from a network we get an error that the application is not from a trusted source and if we want to install the particular application or not.
This error comes because the source is not digitally signed and the Operating System prompts to ask from user if it is a known source to user or if something malicious is being run from network. This is just to protect the end users from the malicious software or Virus attack.
Technically,
This behavior was introduced in Windows XP SP2 because of the addition of the Attachment Execution Services (AES). Every program that is run by using the ShellExecute() API passes through AES. AES considers the downloaded update file to be from the Internet Zone. Therefore, AESdisplays the Open File - Security Warning dialog box. AES examines the file to see whether the file has a file stream of the type Zone.Identifier. Then AES determines what zone the file is from and what level of protection to apply when the file is run.
You can use the below code to suppress this message for your application to work fine.
set oShell= CreateObject("Wscript.Shell")
set oEnv = oShell.Environment("PROCESS")
oEnv("SEE_MASK_NOZONECHECKS") = 1
<Your Code here>
oEnv.Remove("SEE_MASK_NOZONECHECKS")
Please note that you should not set this as a permanent environment variable as it will disable all Zone Checking and it is not recommended.
This error comes because the source is not digitally signed and the Operating System prompts to ask from user if it is a known source to user or if something malicious is being run from network. This is just to protect the end users from the malicious software or Virus attack.
Technically,
This behavior was introduced in Windows XP SP2 because of the addition of the Attachment Execution Services (AES). Every program that is run by using the ShellExecute() API passes through AES. AES considers the downloaded update file to be from the Internet Zone. Therefore, AESdisplays the Open File - Security Warning dialog box. AES examines the file to see whether the file has a file stream of the type Zone.Identifier. Then AES determines what zone the file is from and what level of protection to apply when the file is run.
You can use the below code to suppress this message for your application to work fine.
set oShell= CreateObject("Wscript.Shell")
set oEnv = oShell.Environment("PROCESS")
oEnv("SEE_MASK_NOZONECHECKS") = 1
<Your Code here>
oEnv.Remove("SEE_MASK_NOZONECHECKS")
Please note that you should not set this as a permanent environment variable as it will disable all Zone Checking and it is not recommended.
Subscribe to:
Posts (Atom)