changing directory access using ICACLS.exe at runtime - asp.net

I have the following syntax to change the directory access permission of the LOGO folder in the web application
ICACLS D:\Workspace\SampleProject\LOGO /grant "IIS_IUSRS":(OI)(CI)F.
This works fine if the application is deployed on local IIS, If the web application is hosted on some external server i am not sure what will be the exact path of the LOGO folder,that means cant hard code the path.
so i have written a console application , which gives me the complete path of logo folder on the server and the path is written to sample text file.
my question is their any way to substitute the path "D:\Workspace\SampleProject\LOGO" with the path obtained from text file at runtime ?.

As far as I understand from reading your question and comments, you have a text file with the path of the LOGO folder and you want to run icacls.exe from a batch file to set the folder permissions.
Say, your text file is named path_to_logo.txt and contains a single line with the path. Then the following batch script will do the job:
for /F %%l in (path_to_logo.txt) do ICACLS %%l /grant "IIS_IUSRS":(OI)(CI)F
for /f will loop through all lines in a file (and you have just one), assign the current line to a variable %l and execute what follows the do keyword.

Related

Unable to read xml file when using exe4j to package jar into exe

Recently I encountered a problem when using exe4j to package the jar into exe. My xml configuration file is placed in the same directory of the exe, but after the package is completed, the exe will look for the xml file from the temporary folder.
These are the instructions in the exe4j help documentation
For some applications (especially GUI applications) you might want to change >the working directory to a specific directory relative to the executable, for >example to read config files that are in a fixed location. To do so, please >select the Change working directory to: checkbox and enter a directory relative >to the executable in the adjacent text field. To change the current directory >to the same directory where the executable is located, please enter a single >dot.
The error when i running the exe :
[ERROR] In Log's init,cann't read config file, file=/C:/Users/**/AppData/Local/Temp/e4jEA8.tmp_dir1543543191//sys_log.xml
Why is the program not looking for this xml from the exe's sibling directory, and how can I find it from this directory?
If you are using the "JAR in EXE" mode, use
System.getPrpoerty("install4j.exeDir")
to get the parent directory of the executable.

Get system directory path

I want to upload an image file using an AutoIt script:
WinWaitActive("Open")
Send("D:\sprint8execution\gGastro-mvn\tmp.png")
Send("{ENTER}")
How to give the system-defined path in the script so that if the script runs on any other machine it goes to applicable directory and fetches the image from there?
Have a look to the AutoIt macros. #ScriptDir is the directory that includes the current running script.

IAR project variable like $PROJ_DIR$

Is there any possibility in IAR to add additional project variable like $PROJ_DIR$ to specify my project environment?
I like to keep my project portable and adaptable.
Of course there are, according to the manuals:
Variable / Description
$CONFIG_NAME$ The name of the current build configuration, for example Debug or Release.
$CUR_DIR$ Current directory
$CUR_LINE$ Current line
$DATE$ Today’s date
$EW_DIR$ Top directory of IAR Embedded Workbench, for example c:\program files\iar systems\embedded workbench 6.n
$EXE_DIR$ Directory for executable output
$FILE_BNAME$ Filename without extension
$FILE_BPATH$ Full path without extension
$FILE_DIR$ Directory of active file, no filename
$FILE_FNAME$ Filename of active file without path
$FILE_PATH$ Full path of active file (in Editor, Project, or Message window)
$LIST_DIR$ Directory for list output
$OBJ_DIR$ Directory for object output
$PROJ_DIR$ Project directory
$PROJ_FNAME$ Project filename without path
$PROJ_PATH$ Full path of project file
$TARGET_DIR$ Directory of primary output file
$TARGET_BNAME$ Filename without path of primary output file and without extension
$TARGET_BPATH$ Full path of primary output file without extension
$TARGET_FNAME$ Filename without path of primary output file
$TARGET_PATH$ Full path of primary output file
$TOOLKIT_DIR$ Directory of the active product, for example c:\program files\iar systems\embedded workbench 6.n\arm
$USER_NAME$ Your host login name
$ENVVAR$ The environment variable ENVVAR. Any name within $_ and _$ will
be expanded to that system environment variable.
If you go to Tools > Configure Custom Argument Variables you can add variables that you can address with $VARIABLE_NAME$. Not sure if that's exactly what you were looking for.
As a caution, if you are using IarBuild.exe to build from the command line, the workspace or global values set from "Configure Custom Arguments Variables" are not included in the project files (.ewp) and thus is not expanded by IarBuild.exe at build time. This is not an issue if you only use the IDE to build.
I found a reason for my problem (but it givs another one):
I define a windows "path-variable" like LIB_PATH and put it in the IAR project file with $_LIB_PATH_$.This works as long until i save the IAR-project. Then IAR sets all paths realive to $PROJ_DIR$ :-(

How to copy a license file which is placed with the setup.msi to target directory (setup created with msifactory)

I have created a Setup file i.e. setup.msi , this file contains a website installer
I have a License.xml file that I want to give to my client with the installer (setup.msi).
Before running the setup.msi , client has to make sure that the License.xml file should be in the same directory where setup.msi resist.
I want my setup.msi file to copy the License.xml file to the Destination directory (where website will be installed , this path will be prompted to user for customization)
I am using MSIFactory for creating setup.msi. I am not able to do this. I searched over net but did not get any accurate answer.
I am not familiar with MSIfactory, but in installshield what I would do is, call a batch script to do the copy and pass the target directory as a parameter to it. or use the 'XCopyFile' function to do the copying.

How to stop/start IIS 7 application through command line?

I would like to create a batch file to start one IIS application, and stop another one.
How it can be done using command line?
How to combined it in batch file?
http://www.windowsnetworking.com/articles_tutorials/Configuring-IIS-7-command-line-Appcmdexe-Part1.html
Put this into a file with .bat extension.
#echo off
appcmd start sites "site1"
appcmd stop sites "site2"
Update
Just ensure that appcmd is available anywhere by adding %windir%\system32\inetsrv\ to the PATH environment variable of your system. Alternatively, you can use the full path to appcmd.exe in the batch file.

Resources