Notepad++ save adds weird characters - text

I'm trying to run a task on the Worker Role. I added a file named Startup.cmd with the following content:
icacls "PDFs" /grant Users:(OI)(CI)F
EXIT /B 0
All this does is give the Users group full control to the PDFs folder. The task does run because the Microsoft Azure Activity Log window shows the message Details: Starting role... Application startup tasks are running. [2015-02-04T23:39:28Z] when the Worker Role is deployed. I then log into the machine using Remote Desktop and the security on the folder is not as expected. I then try to run the command manually and I see this:
The file has some weird characters which is making the command fail: icacls.
Can Azure Publishing be causing this?

It looks like your script is being saved with a byte order marker. Try saving the script as ascii or as UTF-8 without a BOM. That might work out better for you.

Related

How to Save Images from A Program Ran from Ubuntu Application Start-up Command

We're trying to run a program at start with Ubuntu's Application Start-up command. We're successfully starting the camera and viewing the images. But the images are not saving to the folder we expect them to be saved too.
The program works flawlessly when started manually from the terminal. Saving into the appropriate folder.
Does anyone have any idea of how to get the images saved but when started from the Application Start-up command upon start-up?
Thanks.
You're not providing a whole lot of details, so my answer may be totally off. To me it sounds like you've created an app that takes a picture with the webcam and saves it to disk. Now you want the app run it when the user logs in, so you've added your app to the list of Startup Applications. The app starts, takes a picture, but can't write it do disk. If that's the case, I'd consider:
Try adding debug logging to your app, so you can see why it fails opening the file. What ever language this app is written in, if opening a file fails, the API will tell you. This information is vital. The easiest is to print to stdout and then, when starting the app, forward it to a log .e.g. /usr/local/bin/myapp &>> /tmp/myapp.log.
Try writing to a location like /tmp where permissions aren't that much of an issue.
Try adding a delay before starting the app, see this list of various approaches on how to do this, the most simple being using this a the command: sleep 10 ; /usr/local/bin/myapp &>> /tmp/myapp.log
If this is all rubbish you need to add more details in your question.

powershell IQY dump script fails

I'm currently working on automating a powershell script to make a dump of a small DB.
The database is accessible through a company Sharepoint and I am leveraging an IQY file exported from said Sharepoint to read the database contents.
When I run the script manually (i.e. calling it from the command line), it works with no issues, but when I try and start the script from Task Scheduler, the following exception is raised:
System.Reflection.TargetInvocationException
the line that is generating the exception is:
$iqy = $xl.Workbooks.Open($query, 2, $true)
Where $xl is a new Excel.Application ComObject, created correctly and $query is a string containing the full file path of the iqy file.
As for my configuration, I'm trying to run my script on a Windows Server 2008R2, using a local administrator user (same user that is supposed to launch the scheduled script), which is also authorized to access the Sharepoint. I'm running Powershell 3.0. I'm not loading any Sharepoint-related snapins.
The only answers I found poking around hinted at granting "Trust" to the IQY file location and the Sharepoint itself in Excel. That did not help.
The Exception also seems to point at a sharepoint issue, but since the script runs fine when started manually, I cannot understand how it could be anything to do with Sharepoint.
Am I missing some intricacy of the Task Scheduler?
Any help would be greatly appreciated.
Never mind, I seem to have found an answer.
If anyone is encountering the same issue, it appear the Excel Com Object has a bug that does not allow it to run from the Task Scheduler if you set it to run regardless of whether the user is logged in.
To circumvent that create the following 2 folders on the machine where the script is supposed to run:
(32Bit, always)
C:\Windows\System32\config\systemprofile\Dektop
(64Bit)
C:\Windows\SysWOW64\config\systemprofile\Desktop
After creating the folders, it worked as expected.
Source: http://social.technet.microsoft.com/Forums/windowsserver/en-US/aede572b-4c1f-4729-bc9d-899fed5fad02/run-powershell-script-as-scheduled-task-that-uses-excel-com-object?forum=winserverpowershell

Azure startup.cmd add new user script

I have a simple startup.cmd script which runs some net commands to create a new user and add the user to the administrator group.
I got the script from this blog. I have run the net commands in a elevated CMD session and they work correctly. but running this on my developer machine just sees the role hanging.
Is there some trick i'm missing?
startup.cmd file contents:
net user dataAdmin thepassword /add
net localgroup Administrators dataAdmin /add
the relevant snippet from the servicedefinition file:
the startup.cmd is set to build action = Content and Copy Always for the copy to output directory
I haven't tried this in azure production yet. I will attempt to push it into staging later today.
UPDATE
At BStateham's suggestion I checked the event logs on my machine:
Under 'Windows Azure' there is a error logged:
User program "..\SLC.DataRole\approot\bin\startup.cmd" exited with non-zero exit code 1
Any idea what that is supposed to mean?
Based on your comments it looks like you discovered this but a critical requirement is that the startup cmd file has the correct encoding, and
"Be sure to create it with notepad or another ASCII text editor… batch
files created in Visual Studio seem to have a byte order mark at the
top that makes them fail when executed."
Also this and this this are good references for some other common issues with startup commands.

Running unverified publisher batch files with powershell

In my powershell script I call a handful of batch files. For each batch file I get the "publisher could not be verified warning" and I have to click run for it to work. This poses some problems for automating this script
Without changing settings on the machine itself, can I make this issue go away?
When you right clic on these script files in explorer do you see in the general tab :
Security : this file come from ...
you can remove it using :
echo "">file.ps1:Zone.Identifier
You'll find more explanation here :

Application Azure will be Aborted when upload publish file with Startup task

I have created web application and one agent (EXE) with it fetch performance counter using WMI Query (compatible with 32 bit) so i have created one Enable32BitAppPool1.cmd file and add it in startup task, content of that file as per below
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.enable32BitAppOnWin64:true
and set property of that file "Copy Always" as per following this link.
Now when i am going to upload that package to Azure then it will be Aborted or in Buzy mode
Can anyone please tell me the reason of this?
It seems your cmd file not working in startup task.
Two possible solution
1> Create .bat file and try in as a start up task for your webrole.
2> other solution is that, try to run the file (.cmd) using system.Diagostic.process.start(...) from some other exe file and set that exe file as a startup task.
There is absolutely no way to know, based on what you've posted, what's going on.
I'd enable remote desktop on that instance and check out the event logs to try and get a handle on what's happening.
If you can't remote desktop in because your startup task is killing it - then disable the startup task, remote desktop in, and try to run what you think the startup task is doing - but manually - so you can see what's actually going on.

Resources