Visual Studio PowerShell AllowDrop Cannot be found on this object Error - winforms

i have been working on a windows form, i have finally completed it and have built it, when i run the application there is an error with the form (there is no error when i am running it on VS)
please see error below, please note i loaded it into ISE so i could see the error
the code this is relating to is
This Is In FORM12.ps1
######################################## This is For Drag And Drop
$handler = {
$_.Data.GetFileDropList() | % {
$listbox1.Items.Add($_)
}
}
$listbox1.AllowDrop = $true
$listbox1.Add_DragEnter({$_.Effect = [Windows.Forms.DragDropEffects]::Copy})
$listbox1.Add_DragDrop($handler)
i don't understand what it means

If you are running your script in an elevated environment or running as administrator, User Account Control (UAC) won't allow you to drag and drop on your program.
Run the program without elevated privileges then you will be allowed to drag and drop on your program.

Related

Why is [PrtSc] button not working in Intellij-Idea or Microsoft SQL Server Management Studio?

I'm using a thrid-party screen capturing application (Screenpresso). It's configured to start screen-capturing when I press PrtSc. And indeed it works except when Intellij has Windows focus. In fact, to screen capture code I have to focus on any other window press PrtSc and then select the area within Intellij.
I've looked through all the settings, and especially the Keymap settings, and I can't see anything else that has been assigned to PrtSc. Of course, I'm not really sure; when I try to find a setting via nothing happens, as pressing PrtSc has no effect.
I know this used to work for me in previous versions of Intellij (though I can't remember what versions). But PrtSc used to work in Intellij just like every other application.
So I guess the question is, why is Intellij eating the PrtSc keypress event? And can I turn it off so that the event gets correctly passed to my dedicated screen capturing application.
Intellij 2019.2.4
Windows 10, 64b
This turned out to be an issue with Screenpresso:
https://www.screenpresso.com/support/hot-keys/
Why shortcut [print screen] key does not always work?
This must be because you run your application with elevated
privileges (with admin rights) (the UAC must have displayed a popup
at startup).
For security reasons, Screenpresso can handle shortcuts
from Windows running with elevated privileges only when it is
installed in Program Files folder.
To fix this, you should install
Screenpresso in Program Files folder which is not the default
behavior:
Uninstall Screenpresso
Run again Screenpresso: Right click Screenpresso.exe and select Run as administrator
Click on the INSTALL on this computer button while holding the Control key or click on the sub-menu Install for all users:
Some users have this problem, first reported 5 years ago: Find here
Crash dumps (java_error_in_*.log in the user's home directory) can help to understand it better.

Requesting administrator privileges in C program?

I'm trying to make a C program that modifies my host file, but I can't just straight up open the file with the program, because Windows blocks it. Is there any way that I can make the program request administrative privileges within the code, or any script I can use to start the program in admin mode?
Right clicking is a solution that allows you to run any program with Administrator privileges. That includes ticking the box in "Properties".
On Windows 7 and later, you can also rename your program so that its name contains setup (like hosts_setup.exe), and it'll automatically be run in Administrator mode (brings up the UAC prompt) if double-clicked in Explorer. Note this only works from double-clicking in Explorer.
You can also take a look at How can I run a child process that requires elevation and wait? . It calls WinAPI and is a fairly native approach. The best solution is to add it in menifest so your program requests Admin at startup.
Shoot, okay, seconds after posting this question, I found a solution. It turns out that you can right click the executable, click properties, and on the compatibility tab, select "Run this program as administrator". Just in case anyone else needed this information.

"Directory Name Invalid" error from Customized TFS Build Definition

I am trying to run an (empty) batch file from a customized TFS Build Definition, but every time the process hits the "Run Script" build activity, I get a "Directory Name is invalid" error.
We are using TFS 2013 Update 4 on Windows Server 2008 R2 Standard, and I am running Visual Studio 2013 from a Win 8.1 Pro on my dev machine.
The batch file in question is at "C:\Builds\SP_Base" on the TFS Server (as shown in the test condition in my customized build template. Here's the template itself (based on GitTemplate.12.xaml, since we are using Git as our source control):
This is the definition for our "Run Script" action:
From the log file, we can see that the test for the directory with the batch file passes without an issue. The same log file then shows the error:
Does anybody know how to resolve this, please?
I've seen other threads discussing the "directory name invalid" issue in other contexts, and the closest match was the one referring to the fact that cmd.exe gets invoked without sufficient privileges.
If we are looking at a symptom of a similar issue here, then what should I do to invoke cmd.exe from a TFS build process without errors?
Currently this is what I have if I look at cmd.exe's properties:
In answer to my question about how to invoke cmd.exe from TFS build process...
I found I can use InvokeProcess activity instead of RunScript in my customized build template. This article helped.
This is my new custom template xaml (including error handling for InvokeProcess):
Also, having added variables ExitCode (Int32) and ErrorMessage (String) as per article, the properties of the InvokeProcess activity now look as follows:
Please note the leading "/c" term in Arguments property for InvokeProcess. Without it, the activity will run and return no error, but the script will not get executed.
Hope this helps somebody with a similar issue.

Unable to open files by dragging them into applications opened from Conemu

I was wondering, why I'm not able to drag files to applications opened by Conemu, like for example emacs, firefox, etc..
How could be this enabled?
Thanks
UPDATE:
I've uploaded a video to illustrate the issue:
Video
It seems that this is nothing to do with ConEmu or Powershell. It's Windows! :-)
Apparently if I open an application as an Administrator, then I'm not allowed to drag files into this application by design and for security reasons.
This is how the UAC works. Drag- and Drop are messages. And sending messages
from a program with normal rights, to an application with admin rights can
cause security issue.
Do Drag & Drop only work with application with the same rights (program
with Admin rights to program with admin rights or program with normal rights to
program with normal rights ).
Source: http://social.technet.microsoft.com/Forums/windows/en-US/cba0e9b1-25f8-40e5-a888-1435d604f68d/run-as-administrator-prevents-drag-and-drop-working

WPF application works fine on my pc but not in the client PC

I have created a WPF application (web scraper), the debug version works as expected on my pc but after copying the files to the clients it shows the User interface and after pressing the button to scrap it doesn't do anything, I am having the same OS as the client (Windows 7 64 bit), I can't guess what the problem is ? can anyone help me ?
Alongside any other diagnostics you are doing to investigate why you can run an app on your machine, but a client cannot run it on his machine is to double check the roles you are both in...
As a developer, you most likely run your development computer with
Full Trust permissions. Therefore, you do not see the same security
exceptions when you debug the application that users may see when they
run it with restricted permissions.
In order to catch these exceptions, you have to debug the application
with the same permissions as the end user. Debugging with restricted
permissions can be enabled on the Security page of the Project
Designer.
When you debug an application with restricted permissions, exceptions
will be raised for any code security demands that have not been
enabled on the Security page. An exception helper will appear,
providing suggestions about how to modify your code to prevent the
exception.
Visual Studio
Here is a snippet to pop up all the various roles...
WindowsIdentity wi = WindowsIdentity.GetAnonymous();
WindowsPrincipal wp = new WindowsPrincipal(wi);
foreach (var e in Enum.GetValues(typeof (WindowsBuiltInRole)))
{
if (wp.IsInRole(e.ToString()))
{
MessageBox.Show(String.Format("{0} is in role {1}", wp.Identity.Name, e.ToString()));
}
else
{
MessageBox.Show(String.Format("{0} is NOT in role {1}", wp.Identity.Name, e.ToString()));
}
}
These things will help you further investigate why the same program behaves differently on two computers driven by two different people.

Resources