Sitecore folder & IIS permissions - iis

When setting up or moving a Sitecore solution, you have to remember to setup the correct folder permissions and IIS permissions.
It something like sections 3.3.3.2 - 3.3.3.9 here:
http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%205,-d-,3/Installation/EXE%20Installation.aspx
The folder permissions are usually setup when using the installer, but not when using the Zip or just moving an existing solution.
You could use the guides (for Sitecore 6) here: http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/Installation.aspx
But going through steps 3.5 to 3.6.5 is bothersome.
Anyone made any scripts or programs that could do this more or less automatically?
It will be greatly appreciated.

Assuming you are playing around with a non-production instance:
in non-production environments, it‘s generally easiest to grant the ASP.NET account and the anonymous Internet user account Full Control of the Website and Data folders as well as all their descendants and grant the NETWORK SERVICE user full control of D:\Sitecore\Databases folder.
So (The permissions are set recursively):
ASP.NET account (IUSR in IIS 7) & Anonymous user: FULL CONTROL OVER:
/Website
/Data
NETWORK SERVICE (default SQL Server account): FULL CONTROL OVER:
/Databases
Alternatively you could Cacls to set permissions to a file/folder from the commandline.
For example you could use the following statement to grant the Administrator user Write AND Delete permissions on c:\file
icacls c:\file /grant Administrator:(D,WDAC)

I am using this script
Option Explicit
Dim fso, path
' get current directory
set fso = createobject("Scripting.FileSystemObject")
path = fso.GetFolder(".").Path
WScript.StdErr.WriteLine "Setting up rights"
WScript.StdOut.WriteLine "Path:" & path
Dim appname
appname = InputBox("Name of the App Pool", , "AppPool")
If appname = "" Then
Wscript.Quit
End If
Dim wsShell
Set wsShell = WScript.CreateObject ("WSCript.Shell")
'wsShell.run "icacls """+ path + """ /inheritance:r"
wsShell.run "icacls """+ path + """ /inheritance:e /grant ""IIS AppPool\" + appname + """:(RX)"
wsShell.run "icacls """+ path + "\App_Data"" /inheritance:e /grant ""IIS AppPool\" + appname + """:(F)"
wsShell.run "icacls """+ path + "\sitecore\shell"" /inheritance:e /grant ""IIS AppPool\" + appname + """:(F)"
wsShell.run "icacls """+ path + "\temp"" /inheritance:e /grant ""IIS AppPool\" + appname + """:(F)"
wsShell.run "icacls """+ path + "\upload"" /inheritance:e /grant ""IIS AppPool\" + appname + """:(F)"
set wsShell = Nothing

Related

Delete directory content using Azure Automation DSC

I am using Azure Automation DSC to deploy some basic configurations on my Azure VMs. However, I am struggling to delete recursively all the content of C:/Temp directory and leave the directory as an empty folder.
I am using the following code:
$temp_dir = "C:\temp\"
File "Clean Temp Folder" # Delete $temp_dir Directory
{
Ensure = "Absent"
Type = "Directory"
Recurse = $true
DestinationPath = $temp_dir
Force = $true
}
As soon as I assign node configuration to the VM, C:/Temp/ folder gets deleted completely, but if I recreate it manually afterwards it won't be deleted on the next DSC run even though the Force parameter is set to true.
Any suggestions are very welcome!
I would recommend to go with Script resource or else if you want to go with File resource only then try something as shown below.
$temp_dir = "C:\temp\"
File "Clean Temp Folder" # Delete $temp_dir Directory
{
Ensure = "Absent"
Type = "Directory"
Recurse = $true
DestinationPath = $temp_dir
Force = $true
}
$temp_dir = "C:\temp\"
File "Create empty Temp Folder" # Create empty $temp_dir Directory
{
Ensure = "Present"
Type = "Directory"
DestinationPath = $temp_dir
Force = $true
}
The issue was on the Azure side. While I was registering nodes in DSC, the configuration mode was set to ApplyAndMonitor.
The bad thing is that the setting was not visible for the already registered node, but after re-registering the issue was solved.
Screenshot

Wrong path when trying to open a batch file via vba

I want to open a batch file via vba. This always was no problem but lately the path is not correct.
The path is always:
C:\Users\ [username] \Documents>
The batch file itself seems to be found because the code is correctly passed through:
e.g. C:\Users[username]\Documents>echo ...
I tried with absolute and with relative path. Both leads to the same problem.
pathDir = ThisWorkbook.Sheets("Info").Range("B1").Value
...
functionPath = pathDir & "\" & paramFunction & ".bat"
Call ShellExecute(0, "open", functionPath, paramECU & " " & paramBackend & " " & paramVIN, "", SW_SHOW)
What could be the problem?
Default shell path of excel is
C:\Users[username]\Documents
So, in vba you can check by using the code
msgbox CurDir
If you need to change path of shell, the command is
ChDir "C:\Desire Path"
In case of you is
ChDir pathDir
If the path is in other drive (not C:) you should change drive before change directory. For example drive D:.
ChDrive "D"
ChDir "D:\Desire Path"
then call ShellExecute without prefix path.

How can I create a setup that installed from command line in install shield 2012

I want to disable the screens in dialog tab, but I also want that the installer doesn't show any screen.
From commandline and install silently.
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
ProcessStartInfo psi = new ProcessStartInfo();
psi.Arguments = "/s /v /qn /min";
psi.CreateNoWindow = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.FileName = desktopPath + "\\" + "Tabcontrol.exe";
psi.UseShellExecute = false;
Process.Start(psi);
If you run an installshield setup in silentmode it requires a record file that contains the information the setups needs. It is not really initially silent it's more like unattended and silent.
Here you can find the information how to create this recordfile: http://helpnet.installshield.com/installshield16helplib/CreatetheResponseFile.htm
Here you will find everything you need to know about any unattended/silent setup: http://unattended.sourceforge.net/installers.php

VBA Check If Sharepoint Folder Exists

I am trying to determine if a Sharepoint folder exists in Excel VBA using the URL path and if not create the folder. I can do this easily if I map the network drive:
myWorkbookBasePath = "Z:Documents\Reports\2013\"
If Dir(myWorkbookBasePath, vbDirectory) = "" Then
MkDir myWorkbookBasePath
End If
However, I can not figure out how to do it using the URL path. If I use
myWorkBookBasePath= "http://sharepoint/Documents/Reports/2013/"
I get error code 52. Can anyone tell me how to make it work with the URL path?
Give this a go
myWorkBookBasePath= "\\sharepoint\Documents\Reports\2013\"
or
myWorkBookBasePath = "http://sharepoint/Documents/Reports/2013/"
myWorkBookBasePath = Replace(Replace(myWorkBookBasePath, "http:", ""), "/", "\")
MsgBox (myWorkBookBasePath)
and in case of a Sharepoint site hosted using https
myWorkBookBasePath = "https://sharepoint/Documents/Reports/2013/"
myWorkBookBasePath = Replace(Replace(myWorkBookBasePath, "https:", ""), "/", "\")
myWorkBookBasePath = Replace(myWorkBookBasePath, Split(myWorkBookBasePath, "\")(2), Split(myWorkBookBasePath, "\")(2) & "#SSL")
MsgBox (myWorkBookBasePath)
MkDir in VBA can only access filesystem and does not understand URL's, so anything you can open in Explorer you can access with MkDir.

IIS 5.1: Programmatically Create Virtual Sub-Directory

Background
I'm trying to automate the creation of Virtual Directories based on the location of an existing Virtual Directory and its sub-directories.
Example:
C:\WebSites\Parent\NewVirtualDirectories
Where Parent is a Virtual Directory and NewVirtualDirectories contains any automated Virtual Directories.
Problem
Using the following Code:
Option Explicit
Dim args, strComputer, strVdirName, strVdirPath, objVdir, objIIS, objWebSite
Set args = WScript.Arguments
strComputer = "localhost"
strVdirName = args(1)
strVdirPath = args(0)
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/1")
Set objWebSite = objIIS.GetObject("IISWebVirtualDir","Root/Parent")
Set objVdir = objWebSite.Create("IISWebVirtualDir",strVdirName)
objVdir.AccessRead = True
objVdir.Path = strVdirPath
objVdir.AppCreate (True)
objVdir.SetInfo
WScript.Quit
I can create children under Parent, but they show up Directly under the parent. I need them to be in the Sub Folder.
I get: http://localhost/Parent/NewSite
I want: http://localhost/Parent/NewVirtualDirectories/NewSite
I've tried
Set objWebSite = objIIS.GetObject("IISWebVirtualDir","Root/Parent/NewVirtualDirectories")
but NewVirtualDirectories is not a Virtual Directory (an I don't want it to be) so I get an error. I can get the desired effect when I do this manually in IIS manager, but I can't figure out how to automate it.
Any help would be greatly appreciated.
EDIT
For those who are facing similar problems, I found a great resource for VBScript-ing
http://www.cruto.com/resources/vbscript/vbscript-examples/vbscript-sitemap.asp
After doing a lot more digging (trial and error) I was able to figure it out.
By referencing the existing folder as a IISWebDirectory, I was able to select it and then create an application without creating a virtual directory.
Option Explicit
Dim args, strComputer, strVdirName, strVdirPath, objVdir, objIIS, objWebSite
Set args = WScript.Arguments
strComputer = "localhost"
strVdirName = args(1)
strVdirPath = args(0)
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/1")
Set objVdir = objIIS.GetObject("IISWebDirectory","Root/Parent/NewVirtualDirectories/" + strVdirName)
objVdir.AccessRead = True
objVdir.AccessScript = True
objVdir.AppFriendlyName = strVdirName
objVdir.AppCreate (True)
objVdir.SetInfo
WScript.Quit

Resources