User access control dialog box with python executable - uac

I have multiple python scripts which I have converted to executables using py2exe. When I run them I get a UAC dialog box saying
'Do you want the following program from an unknown publisher to be able to make changes to your computer.'
I'm running windows 7, 64bit, python 3.3.
In order to be sure it wasn't due to my code, I copied the following simple script from the web and created an exe. Still the same problem.
import ctypes
from ctypes import wintypes
def get_appdata_directory():
CSIDL_APPDATA = 0x001a
dll = ctypes.windll.shell32
app_data_directory = ctypes.create_unicode_buffer(wintypes.MAX_PATH)
found = dll.SHGetFolderPathW(0, CSIDL_APPDATA, 0, 0, app_data_directory)
return app_data_directory.value
appdata = get_appdata_directory()
The script merely finds the path to the appdata directory.
What needs to be done in order to avoid the UAC dialog box?

You need to create an "Assembly Manifest" for your application. It has to declare requestedExecutionLevel=asInvoker, and then either
embed it as a resource (RT_MANIFEST)
or have it in the same folder as your exe, and named MyApp.exe.manifest

Related

Open a pdf with default windows behaviour from a WPF application

I want to open a PDF with the default windows behaviour the user has saved (e.g. internet explorer, adobe, whatever).
I found this solution
Opening a .pdf file in windows form through a button click
and implemented it here:
ProcessStartInfo startInfo = new ProcessStartInfo("MyPdfPath");
Process.Start(startInfo);
Sadly I got an Error:
System.ComponentModel.Win32Exception: "The specified executable is not a valid application for this OS platform."
I tried to google this error, but nothing of the first ten solution ideas worked.
The system is treating it like an executable, one way to get the document behavior is to set UseShellExecute to true:
ProcessStartInfo startInfo = new ProcessStartInfo("MyPdfPath");
startInfo.UseShellExecute = true;
Process.Start(startInfo);

Get a list of all applications that SikuliX currently sees

I have an application that doesn't appear to be responding to SikuliX's (v 1.1.2) .focus(). It is one of three custom WinForms applications I have running. I found this link pertaining to my exact situation, but the suggestions did not help.
I have been able to get the code to work for Chrome, SQL Server, and other random applications I have running at the time. The problem seems to come in when I have more than one type of application running. If my applications are named "Version Launcher", "Device 1", and "Alternative", I am able to switch to "Version Launcher", but "Device 1" and "Alternative" aren't found.
class myDevice:
def startApp(self):
#my_app = App("Chrome") # works
#my_app = App("Visual Studio") # works
#my_app = App("Version Selector") # works
#my_app = App("Device 1") # does NOT work
my_app = App("Alternative") # does NOT work
my_app.focus(); wait(1)
my_device = myDevice()
my_device.startApp()
In order to rule out a bad name (perhaps, on some level, the application is not really named "Device 1"), I'd like to build a list of every application that Sikulix can detect at runtime. Has anyone ever tried such a thing? I've searched all over the documentation and cannot find any features that allows for this sort of querying.
Raimund Hocke, the maintainer of the SikuliX project, answered my question over on launchpad.
https://answers.launchpad.net/sikuli/+question/664004
In short, SikuliX uses the 'tasklist' command in Windows to grab the list of available applications.

Adobe Flex OpenWithDefaultApplication Movie

I am working on an Adobe Air application that I would like to be able to launch a movie using the default application. The code I am trying is:
var file:File = new File;
//currentMovie.ConfiguredPath = 'D:\\Movies\\TestMovie.avi';
file.nativePath = currentMovie.ConfiguredPath;
file.openWithDefaultApplication();
I have also tried this:
//currentMovie.ConfiguredPath = file://D:/Movies/TestMovie.avi'
navigateToURL(newURLRequest(currentMovie.ConfiguredPath));
The first option does nothing. No application opens, no errors, nothing. The second option worked but it launches a separate window, downloads the file to the local user's download directory then opens the file (as long as you click "Open"). This is not exactly the behavior that I was hoping for.

Can i open directory from jump list

Im writing WPF application and want to add ability to call jump list and open program configuration, app.config or log directory from it. Is it possible(cant find the way to do that..just JumpTasks with application path and JumpPath with path to file, and not just path to be opened via explorer)?
Found answer here. Seems that JumpList wasnt designed for opening anything but files or applications, associated with current program. So that when we see directories in explorer tasklist -it actually means: use explorer with parameters. By the way ill try to use it.
Update
made it with such code:
string explorerPath = #"%windir%\explorer.exe";
JumpTask path = new JumpTask
{
CustomCategory = "Paths",
Title = "Open program directory",
IconResourcePath = explorerPath,
ApplicationPath = explorerPath,
Arguments = #"/root," + AppDomain.CurrentDomain.BaseDirectory,
Description = AppDomain.CurrentDomain.BaseDirectory
};
Im leaving this answer here, because someone can have similar incomprehension.

Can't get rid of a deleted Settings reference in DataSet.Designer.vb

I had a connection string to a MS Access DB file, Foo.accdb, defined and used in my project. It was defined as a connection string Setting in the Settings section of my project properties. The program referenced the connection string setting and everything worked fine.
Then I decided to replace Foo.accdb with two different DB files, A.accdb and B.accdb each of which would be used under different circumstances. I added connection strings for them in Settings and removed the Setting definition for Foo.accdb connection string.
The name of my application is Foo and the name of the Foo.accdb connection string was FooConnectionString.
But now when I build the program both in debugger and for release I get the following error message:
'FooConnectionString' is not a member of 'Foo.My.MySettings'.
The offending reference, in file FooDataSet.Designer.vb, is:
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Private Sub InitConnection()
Me._connection = New Global.System.Data.OleDb.OleDbConnection
Me._connection.ConnectionString = Global.Foo.My.MySettings.Default.FooConnectionString
End Sub
What is going on here? FooConnectionString is not in any other file in the project directory nor in the My Project subdir. I completely got rid of it in my code and in my project properties yet it persists in FooDataSet.Designer.vb (whatever that is).
While researching this on the web I saw a recommendation to select the FooDataSet.xsd file, right click it and execute the "Run Custom Tool" option. I did this and it appears to rebuild FooDataSet.Designer.vb (the time stamp changes) but the problem persists.
I also tried removing the offending reference by manually editing FooDataSet.Designer.vb but that gave me some other error message.
Why is this old reference staying around and what can I do about it?
This is a standalone app. I'm using VS2008 Standard Ed., VB.Net 3.5
Thanks.
Open the FooDataSet XSD file in a text editor. Right click on dataset in the solution explorer and select "Open With..." and the select XML (text) Editor or open it outside the solution.
Look for the <Connections> tag near the top of the file. Remove the line that looks like this
<Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="FooConnectionString" ConnectionStringObject="" IsAppSettingsProperty="true" Modifier="Assembly" Name="FooConnectionString(Settings)" ...

Resources