How to get the target path of a shortcut in windows scripting? - wsh

From what I have read until now, you can get the TargetPath property of an objet of class Shortcut, which is the result of the method CreateShortcut of WScript.Shell.
But I have not found any way to get the target path of an existing shortcut.

In javascript:
var sh = WScript.CreateObject("WScript.Shell");
var sc = sh.CreateShortcut(shortcutPath);
var targePath = sc.TargetPath;
It took me some time to understand it. So I guess there will be at least one person happy to find the answer here.

by using .path property?
http://www.bigresource.com/VB-Get-the-stored-path-from-a-shortcut--UWlkOW9XKz.html

Related

Graph Api: search file for exact match

I have a file called "ABC_file1.docx".
I want to perform a search of a specific file name in a specific folder.
My code is:
var fileName = "ABC_file1.docx";
var files = _graphClient
.Drives[<My_Drive_ID>]
.Root
.ItemWithPath("My_Sub_Folder")
.Search(fileName)
.Request()
.GetAsync()
.Result;
Unfortunately this works not only for my file, but also for a similar file name, like "ABC_ABC_file1.docx", and that's not what i need.
How can I search for exact match?
Have you tried leveraging documentation here for searchable site properties and see if this helps.
Thanks!
I just found a solution and seems that the "Search" method is not what it needs for exact match file search.
It's better to use "Filter" rather than "Search" like this:
var fileName = "ABC_file1.docx";
var files = _graphClient
.Drives[<My_Drive_ID>]
.Root
.ItemWithPath("My_Sub_Folder")
.Children
.Request()
.Filter($"name eq '{fileName}'")
.GetAsync()
.Result;
This resolve not only the problem of the searching about exact match, but also the issue which renaming a name on Sharepoint the update is being visible after 10/15 minutes (known issue).

Laravel 5.1 - Retrieving single Models using string instead of the name of the model

Sorry for title. I don't know what to write.
This is my problem:
If i write this is all ok:
$obj_license = License::where('licenses.company_id',$company->id)->first();
But this throw an error:
$license='License';
$obj_license = $license::where('licenses.company_id',$company->id)->first();
ERROR: Class 'Butchery_license' not found
This is just an example. I really need to have the second way working. There is a solution?
Try to use full path to a class:
$license='App\License';
$obj_license = $license::where('licenses.company_id',$company->id)->first();

Vaadin: How do I add options to a combo box?

I have a combo box that I am trying to add options to. How Do I go about this? This is what I have so far:
ComboBox contactPrefixNametf = new ComboBox("Prefix");
contactPrefixNametf.setItemCaption(contactPrefixNametf, "Mr");
fLayout.addComponent(contactPrefixNametf);
contactPrefixNametf.setImmediate(true);
I guess .setItemCaption() is not the correct method? What is the correct method?
Thank you in advance!
Use addItem() method:
final ComboBox my_combox_box = new ComboBox("My Combo Box");
for (final My_object mo: list_of_my_objects)
{
my_combox_box.addItem(mo);
my_combox_box.setItemCaption(mo, mo.name());
}
This example uses addItem inconjunction with setItemCaption() to store the actual object selected by the user with a display friendly name (if toString() is not appropriate).
myComboBox.addItem("Option 1");
(Especially if you are new to Vaadin), I suggest to try Viritin add-on and its TypedSelect variant of ComboBox. Its well typed API makes many things ridiculously simpler. For instance it has a (typed) setOptions method and its value change listeners provide the value directly instead of through untyped Property interface.
A code example of its usage:
List<Person> options = service.findMyPersons();
TypedSelect<Person> select = new TypedSelect<>(Person.class)
.withSelectType(ComboBox.class);
select.setOptions(options);
// If toString() representation is not good, modify it to something else
select.setCaptionGenerator(person -> person.getFirstName() + person.getLastName());
select.addMValueChangeListener(event -> {
Person person = event.getValue();
});
Disclaimer: I'm the maintainer of Viritin, but also have maintained Vaadin for 8 years and nowadays work as its developer advocate.

Use Content instead of Document in Umbraco (v6)

I would like to update some obsolete code from umbraco v4 in the updated to v6 solution.
I have
entitiesFolder = new umbraco.cms.businesslogic.web.Document(folderId);
entitiesFolder.ReorderChildren(
entitiesFolder.Children.OrderBy(fdoc => fdoc.Text),
refreshEntireCache);
Now the recomendation instead of obsolete Document is to use Umbraco.Core.Models.Content. How? Didn't find (as usual for Umbraco) any documentation about... (
// new version
var toto = new Umbraco.Core.Models.Content(??)
toto.SoirtChildren(???)
Are you doing this from a razor view? If so you can do:
var nodeId = 123;
var myNode = Umbraco.TypedContent(nodeId);
var property = myNode.GetPropertyValue<string>("myStringAlias");
If you're doing it from a class or something you'll have to use something like:
var helper = new UmbracoHelper(UmbracoContext.Current);
var nodeId = 123;
var myNode = helper.TypedContent(nodeId);
(This is untested but it should work..)
If you are just querying data and need to sort it, using the umbracoHelper is a great way to go. It only hits the xml cache in App_Data/umbraco.config, so you don't hit the database.
However, if you are attempting to programatically sort some of the nodes in the content tree, you will need to use the ContentService. You will need to use the ContentService whenever you actually want to programatically modify content nodes. You will also find a similar MediaService for media.
https://our.umbraco.org/Documentation/Reference/Management-v6/Services/ContentService
ApplicationContext.Current.Services.ContentService.Sort(...)

Call javascript in sharepoint custom field

I am creating a custom field in SharePoint 2007. I have seen other solutions where the current site URL was default value of a text field.
How can I get this current site URL?
I have got one answer whiches states that I shall use JavaScript, but where do I put the script?
I hope you can help.
BR
To answer 1
I am new to SharePoint and am not quiet sure where to put the java script. Normaly i just give the initial value to the field in the FieldEditor.cs file but how can I do this with the javascript?
Here follows a picute of my files.
I have tried to put it into FiledEditor.cs but this results in the value of myString is written in the top of the web page.
Here is my current code:
string myScript = "var currentUrl = document.URL; LabelLookupFieldTargetURLText.Text = currentUrl;";
Page.ClientScript.RegisterClientScriptBlock(LabelLookupFieldTargetURLText.GetType(), "LabelLookupFieldTargetURLTextJavaScript", myScript);
I found the answer my self. I don't need to use a java script. I can just use SPContext.Current.Site.Url
use javascript:
var nowUrl = document.URL;
yourTextfiled.value = nowUrl;
you can read this:http://www.w3schools.com/jsref/dom_obj_document.asp

Resources