how to get application name using .exe in C#? - c#-3.0

I am new in C#, I want to get the application name (Which is displaying in task manger app part) using .exe.
I have googled it but didn't found useful information.
I want to Description information for each exe.
Thanks,

You can use the Process class located under System.Diagnostics :
using System.Diagnostics;
...
var allProcceses = Process.GetProcesses();
//loop throught processes
string process_description= process.MainModule.FileVersionInfo.FileDescription;
This answer provides some information about the Process class.
NB : you may have some issues when trying to access some processes running under SYSTEM credentials : see this post.

Related

Creating a custom powershell module without exposing code

I want to create a custom powershell module that I can distribute without exposing the code. The script includes API calls with app specific private keys that I don't want to compromise. I've seen a lot of discussions about this over the years, but nothing that really solves my problem.
Is there a good way to create a custom powershell module without exposing the underlying code? I want to be able to distribute the powershell module, for others to import or install.
this may be what you are looking for : https://www.powershellgallery.com/packages/ps2exe/1.0.11
but be careful, the API key will still be in the compiled file at someplace. You can try and cipher it, but if it's needed for your script, it will be in your file no matter how you try to hide it. the question is why do you need to ship it inside your script in the first place ? I mean that any of your script's user will be using your private key which is likely not what you want to do

Is there a way to execute google apps script from PostgreSQL or from Bash?

I have hundreds of google spreadsheets which all have the same script in them. I'd like to execute a specific google spreadsheet by ID either from PostgreSQL or from Bash. Is there an easy way to execute scripts? I prefer not having to learn python.
For example, I have spreadsheet id 1HGo8V-P5S-z4oCUiAKULrkZRFlzRHEalJqUFLiP and I'd like to execute function Refresh() via Bash or Postgresql.
Is the API the only route? https://developers.google.com/apps-script/api/how-tos/execute
So far my consideration is to create a python executable and execute it from a postgresql function. https://developers.google.com/apps-script/api/quickstart/python
Edit: It looks like if I want to execute any app script, each spreadsheet would need a google project (manually created). There has to be an easier way to do this, manually creating a project for every spreadsheet doesn't make sense.
Reference: https://developers.google.com/apps-script/api/how-tos/execute
The script being called and the calling application must share a Cloud
Platform project.
Solution:
Deploy web apps is the solution I ended up going with thanks to #Tanaike
You want to execute the container-bound script of Spreadsheet.
You want to execute the script from local PC or outside of Google.
You want to execute the script from Spreadsheet ID.
If my understanding is correct, how about this answer?
Retrieving project IDs of container bound script:
I think that this is the difficult problem in your situation. In the current stage, there are no methods for retrieving the project ID of the container-bound script from the parent Google Docs (in this case, it's Spreadsheet.).
This has already been reported at https://issuetracker.google.com/issues/111149037 as a Feature Request. But unfortunately, this has not been achieved yet.
By this, the project IDs are required to be retrieved manually.
For example, you can retrieve the project IDs at Developer Hub.
When you select a project, you can see the project ID at the URL of https://script.google.com/home/projects/### projectId ###.
From above situation, the project IDs are required to be manually retrieved from each Spreadsheet you want to run the script. I apologize that I couldn't find a workaround for this situation.
Executing script:
I think that there are 2 patterns for executing the script. You can select from 2 patterns.
1. Use the method of scripts.run in Apps Script API
This is also mentioned in your question.
Function in the script is execute using API.
You are required to create only python script at local side.
In this case, the access token retrieved by the OAuth2 process is required at local side.
I think that in this pattern, the script can be simple.
2. Use Web Apps
By accessing to Web Apps, function in the script is execute.
In this case, in order to execute the script, it uses scripts.run in Apps Script API, because of large number of Spreadsheets in your situation. When user accesses to Web Apps, the script of Spreadsheet is executed by the script of Web Apps. Because Google Apps Script is used, the access token can be easily retrieved.
You are required to create a python script for accessing to Web Apps at local side, and Google Apps Script at Google Side (Web Apps).
In this case, you can run the script with and without the access token at local side.
I think that in this pattern, the method of access can be simple.
References:
scripts.run method
Web Apps
Taking advantage of Web Apps with Google Apps Script
If this was not what you want, I apologize.
Edit:
From the discussions, I thought that in the case of your script Refresh(), the following flow is suitable.
1. Deploy Web Apps using the script of Refresh() like an API.
2. Call the API using python script and curl.
By this, the script of Web Apps is run and you can reflect the result of Refresh() for all Spreadsheets.
Sample script:
function doGet() {
var spreadsheets = ["spreadsheetId1", "spreadsheetId2",,,]; // Please set spreadsheet ID here.
for (var i = 0; i < spreadsheets.length; i++) {
SpreadsheetApp.openById(spreadsheets[i])
.getSheetByName("Sheet1") // If you want to also put values to other sheet, please modify this.
.getRange(1, 1)
.setValue(new Date());
}
return ContentService.createTextOutput("Done.");
}
When Web Apps is deployed, the authorization screen is opened. But this authorization is only one time.
Deploy Web Apps:
Before you request to Web Apps, please deploy Web Apps.
On the Script Editor
Publish -> Deploy as Web App
Create new Project version
At "Execute the app a"s, select "Me"
At "Who has access to the app", select "Anyone, even anonymous"
Click "Deploy"
Copy "Current web app URL"
Click "OK"
Curl sample:
If you use curl command, please use as follows.
$ curl -L "https://script.google.com/macros/s/#####/exec"
Note:
When you modified the script, please redeploy Web Apps as new version. By this, the latest script is reflected to Web Apps. This is an important point.
Note:
Also you can use the spreadsheet IDs for requesting and you can directly includ them in Web Apps. (In the sample script, the latter is used.)
If you want to use the spreadsheet IDs for requesting, please be careful. The number of workers for Web Apps is required to be less than 30. Ref

N2CMS Installation - Start node not appearing

I'm trying to integrate N2CMS into an existing application. I'm in the middle of the installation and have been following the documentation supplied for integrating into an existing application.
I'm up to the 'Add Content Package' part of the installation'. However, the 'HomePage' start page is not appearing under the 'start node' drop down list (under 'Manually Insert Nodes'). I've been trying to figure this out for a few days now, looking at various sources but nothing seems to work.
I'll post the Content Item below (the cs code that the installer should be picking up on). All I really need is a CMS that is easy to integrate into an existing website, which is why I went with N2CMS. But the poorly maintained documentation and lack of support really makes me want to try something else. Unfortunately every CMS wants you to use their system from scratch. If anyone knows another Open Source CMS which is easy to integrate into an existing website, please let me know.
Here's the cs code (HomePage.cs, under the 'Models' Folder)
namespace ExistingApplication.Models
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using N2;
using N2.Web;
using N2.Details;
using N2.ContentItem;
using N2.Installation;
[N2.Definition("My page", "MyPage", "A simple page with a chunk of text", "The tooltip", 1, Installer = InstallerHint.PreferredStartPage, TemplateUrl = "~/UI/Home.aspx")]
[N2.Details.WithEditableTitle, N2.Details.WithEditableName]
public class HomePage : N2.ContentItem
{
}
}
By the way the url that 'TemplateUrl' points to does exist. Thanks in advance.
Try modifying HomePage definition by implementing (empty) interface IStartPage
public class HomePage : N2.ContentItem, IStartPage
IStartPage is marker interface that is used exactly for this purpose - so that N2 can distinguish regular pages from those that can serve as Start Page of the site.

How to suppress display of password in Selenium RC window

I am writing some Selenium RC tests using the perl library WWW::Selenium. At the beginning of the test I need to login to a web form using my username and password.
I noticed that my password is displayed in the Selenium Remote Control "Command History" window as type(password, secret).
Is there any way to suppress the display of the password? Maybe there is a command other than type I can use?
Unfortunately no. You could go into the Selenium core and change it to show ******* when it finds a field named password.
Beware though that this could make life difficult when debugging
I guess we can do this using native methods support.
Think logically every native methods in selenium will be sent to the operating system not to the browser.
So if you use any of the native methods, the flow is like this:
Client Program ----> Selenium RC server ----> to the operating system (in Java this is done using Robot Class)
But all the other non-native methods flow is like this:
Client Program ----> Selenium RC server ----> to the Browser
So, the Command History window operates at the Browser level and the native methods will not reach there.
Here is the code:
selenium.focus("locator");
selenium.keyPressNative("key code"); // this will not be shown in command history
Here the key code is only for one character and if you want string (more than one character), we should rely on our client program to implement the logic.
I have given that code in my previous answers to other posts. If you need it personalised post our exact requirement so that I can give that code tailored to your need.

How do I communicate between two modules in GWT

Hi I am currently facing communicating with two GWT modules.
1. enquiry.html
2. info.html
In enquiry.html i have search results on click of a hyperlink I need to open the info module. Its working fine in my development environment, but when I deploy in linux its causing issue.
Basically when the info.html is loading up, its not able to identify the info.nocache.js
Any help will be highly appreciated.
You can put parameters on the URL, like info.html?resultId=432001
Then, in your code, you can access resultId with
String resultId = com.google.gwt.user.client.Window.Location.getParameter("resultId");