create service in NSIS with binpath in quotes - nsis

Up to today, I was using the follwing code in .nsi file to create a service:
nsExec::Exec 'SC CREATE "MyService" binpath= "$APPDATA\My App Folder\service\SService.exe" start="auto"'
nsExec::Exec 'sc description "MyService" "Starts The Service"'
It worked great, but as of today the service created cannot be started with the error: error 193 0xc1, or in other words, the path to service is incorrect. I opened registry Editor Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService and changed C:\ProgramData\My App Folder\service\SService.exe to "C:\ProgramData\My App Folder\service\SService.exe" (added quotes) and it started working again.
The question is, how can I create a binpath with "" around it? I tried
nsExec::Exec 'SC CREATE "MyService" binpath= "$\"$APPDATA\My App Folder\service\SService.exe$\""
but the service is never created. What is the correct syntax to create a binpath with "" around it in NSIS? If you have any idea, why windows suddenly decided that it wont accept my path without the "", please share that knowledge as well.

This has nothing to do with NSIS, you are simply not using the correct syntax for sc.exe. sc.exe probably uses the MSVC rules for command line parsing which means you must use \".
nsExec::Exec '"$sysdir\sc.exe" CREATE "MyService" binpath= "\"$APPDATA\My App Folder\service\SService.exe\"" start= auto'
Pop $0 ; Exit code

Related

IIS - Setting the physical path of an Application with appcmd

In IIS, I have a web site "Default Web Site" with an application "test2". I want to set the physical path of that application to "E:\temp\out1". That directory already exists.
When I run this in Powershell (as an administrator):
appcmd.exe set app "Default Web Site/test2" -[path='/'].physicalpath:E:\temp\out1
I get this error message:
ERROR ( message:Malformed collection indexer; format is [#position,name='value',name2='value2',...]. The #position specifier is optional, and be '#start', '#end', or '#N' where N is a numeric index into the collection. )
I have no idea what that means.
Would very much appreciate a working example of using appcmd to set the physical path of an IIS application.
Turns out that the command in my question actually works on Command Prompt. However, I tried to run it from a Powershell prompt, and there I got the error message.
I couldn't find a way to run the command from Powershell. In the end, my solution was to write the command to a temporary .bat file, then execute that file from Powershell.
If I set my double quotes like this it works from Powershell prompt.
appcmd.exe set app "Default Web Site/test2" -"[path='/'].physicalpath:E:\temp\out1"

Creating/Migrating rBac in Yii2

I'm just getting started with Yii2 and I am following a tutorial here about setting up Yii2/AdminLTE and I am unable to finish the setup as I am getting errors in Terminal on the last step.
The part I am not able to finish is:
finaly we create rbac dbmanager with simple code, you can see in
folder "console/RbacController" with specific level for :
Admin : can do everything Editor : can edit, add and view Author : can
add and view viewer ; just viewer create rbac :
"yii migrate --migrationPath=#yii/rbac/migrations"
"yii rbac/init"
dont forget to chmod -R 777 on your web/assets if linux environment
and please free to update your setting on menu setting.
So in terminal on my mac, I tried both:
yii migrate --migrationPath=#yii/rbac/migrations
with the error: -bash: yii: command not found
and
/.yii migrate --migrationPath=#yii/rbac/migrations
with error: -bash: /.yii: No such file or directory.
I was able to complete the beginning of the tutorial, it is just this last step. I am already working in my yii2-advanced-adminlte directory
UPDATED:
Added screenshot of terminal window
Normally the yii command is located in
fro advanced template in project directory parent of backend, frontend, console and not in console
be sure of find the right dir and then accessing this try launche your command
yii migrate --migrationPath=#yii/rbac/migrations
eventually adjust your path to rbac/ migrations
Found it out, the problem was using MAMP I had to manually set the php bin to 5.5.23 in terminal because once I started down the path scaisEdge showed me I was getting a No such File or Folder error.
Eventually this is the command that worked for me (check your php MAMP path):
/Applications/MAMP/bin/php/php5.5.23/bin/php yii migrate
Source link: http://www.yiiframework.com/forum/index.php/topic/47043-error-on-using-db-migration-w-mysql#entry222568

Azure Websites Git Deployment dropping "/" in SCM_BUILD_ARGS

Description
We are in a current project based on MVC4/Umbraco using Azure Websites to host it.
We are using SCM_BUILD_ARGS to change between different build setups depending on which site in Azure we deploy to (Test and Prod).
This is done by defining an app setting in the UI:
SCM_BUILD_ARGS = /p:Environment=Test
Earlier we used Bitbucket Integration to deploy and here this setting worked like a champ.
We have now switched to using Git Deployment, pushing the changes from our build server when tests have passed.
But when we do this, we get a lovely error.
"MSB1008: Only one project can be specified."
Trying to redeploy the same failed deployment from the UI on Azure works though.
After some trial and error I ended going into the deploy.cmd and outputting the %SCM_BUILD_ARGS% value in the script.
It looks like the / gets dropped from SCM_BUILD_ARGS but only when using Git deploy, not Bitbucket Integration or redeploy from UI.
Workaround
As workaround I have for now added a / to the deploy.cmd script in front of the %SCM_BUILD_ARGS%, but this of course breaks redeploy, since we then have //p:Environment=Test in the MSBuild command when the value of %SCM_BUILD_ARGS% has been inserted.
:: 2. Build to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
:: Added / to SCM_BUILD_ARGS
%MSBUILD_PATH% "%DEPLOYMENT_SOURCE%\www\www.csproj" [....] /%SCM_BUILD_ARGS%
) ELSE (
%MSBUILD_PATH% "%DEPLOYMENT_SOURCE%\www\www.csproj" [....] /%SCM_BUILD_ARGS%
)
Question
Anyone know of a better solution for this problem or is it possibly a bug in Kudu?
We would love to have both deploy from Git and Redeploy working.
Could you try changing from "/" to "-"? For instance, AppSettings from /p:Environment=Test to -p:Environment=Test, see if it helps.
-p:Environment=Test did not work for me, the setting which worked for me at the time of this writing (September 2015) was
-p:Configuration=Test
There is clearly a Kudu bug in there, and you should open an issue on https://github.com/projectkudu/kudu. But for now, I can give you a workaround.
Instead of using an App Setting, include a .deployment file at the root of your repo, containing:
[config]
SCM_BUILD_ARGS = /p:Environment=Test
I think this will work in all cases. I suspect the bug has to do with bash messing up the environment in post receive hook scenarios, which only apply to direct git push but not to Bitbucket and Redeploy scenarios.
UPDATE: In fact, it's easy to see such weird bash behavior. Try this:
Open cmd.exe
Run: set foo=/abc to set a variable
Run bash
From bash, run cmd to launch a new cmd on top of bash (so cmd -> bash -> cmd)
Run set foo to get the value of foo
Result:
FOO=C:/Program Files (x86)/git/abc
So the value gets completely messed up. The key also gets upper cases, though that's mostly harmless. Strange stuff...

Java PATH not set when creating a Azure Paas Role

I am creating an Azure PaaS role which sets the PATH variable for java.exe .
I have a background task which does that.
The startupApp.cmd looks like
setx PATH %PATH%;%CD%\jdk\bin\ /m
cscript /NoLogo util\unzip.vbs jdk.zip "%CD%"
Call the bat file to start my application.
When the VM starts I see that the PATH environment variable is correctly set and points to where the jdk\bin folder. My application however fails to start with the error "java is not recognised as an internal or external batch command".
JAVA command to start my app is
java %JAVA_OPTS% %LOG_OPTS% %LOG4J_OPTS% -cp my_app.jar %MAIN_CLASS%
Here is the confusing path,
After I log into the VM and open a command prompt window and type java I see that it works fine.
If I restart the VM, the java command to bring up my app runs fine and I and my app too starts fine.
There is a significant difference between setx and set function:
set takes effect in local cmd context. Meaning once you exit or close the cmd window, you lose the environment variable.
setx takes effect in future cmd context. So you won't see the environment variable and its value in the current cmd. You need to open a new cmd window to see it.
If you want to use it global and immediate you should use both functions side by side.
Description taken from: http://batcheero.blogspot.de/2008/02/set-and-setx.html

require_once of certain file works on local windows, not on dev linux machine

I'm trying to integrate Goutte http://github.com/fabpot/Goutte into my existing symfony 1.4 project and am running into a problem.
I have everything working on my local wamp server, here are the two lines in question:
require_once('path_to_goutte.phar');
$client = new Goutte\Client();
Now to debug I've put a print statement before and after the require_once statement and the second print statement doesn't get fired off. No error logs are generated - the error is silent and very frustrating.
Any ideas as to why this might be happening?
"No error logs" is something that should be fixed! Check your php configuration (the php;ini file). Is the log_errors setting set to on?

Resources