Reading Values from Known file located on system - json

I'm new to Stack Overflow, otherwise I would have commented to the primary question in this post...
UWP apps accessing files from random location on system
My situation is similar, but different. It seems that in the post above, that they are trying to read values from a file selected by the user via file picker.
Where I differ is I would like to read a file created my SCCM team, stored on every computer within company. This file will have values like HD Serial Number and Windows Creation date. (values that I can not easily read without doing something like Windows Brokered Component). [Good article here if anyone interested]
Since I know the path of file ahead of time, I'm hoping I can just do like so...
(not on my VS2015 pc, pardon my hacked logic... Hopefully my answers will magically come back in Cut&Paste code ;-))
if
file exist within %localappdata%\MyAppName\ImportedValues.JSON
else
Open FilePicker (location of PowerShellScript that will rerun creation of JSON file)
JSON File Sample
{
"Hardware": {
"TerminalID": "NameOfThisComputer",
"HardDriveSN": "111111111",
"HardDriveModel": "SamsungSSD",
"StagingStartDate": "Thursday, September 17, 2009 3:58:54 PM"
}
}

Your UWP app doenst have access to read any file on the computer. SO they have to place it in the appdata folder as you can find here: http://caioproiete.net/en/physical-location-of-windows-store-applications-and-data-on-a-pc/
or it need to be opened via filepicker.

Related

Changing DriveApp.Permission of a file/folder

I am spending hours (literally) trying to find a way to change the DriveApp.Permission of my script (for web App).
Actually, its value is VIEW, not allowing me to create folders, files or edit them (read only).
The script is configured to run as "me", accessible for anyone.
I have checked the owner of the folder ( FOLDER.getOwner().getEmail(); ) and owner of the user/session ( Session.getActiveUser().getEmail() ).
Not surprisingly, they've returned the same value. I have read THIS, but without success in retrieving any useful information.
I think, the problem is around the DriverApp.Permission value.
I was brief as a possible, I think. Could someone help me?
To put it clear: the script, the driver, etc., all of them belongs to me ( \o/ ).
Example:
DriveApp.getRootFolder().getFoldersByName( "ExistingFolder" ).next().createFile( "No_authorized_it_will_not_be_created_and_will_trigger_a_exepction" , "Some TEXT" );
Google GET response (translated/approximated)
Exception: You don't have permission to call DriveApp.Folder.createFile. You need to have permissions :https://www.googleapis.com/auth/drive (line 135, file "InternalDriver")
With support of #Copper and suggestion of #TheMaster, my solution:
Add this JSON object to the manifest
"oauthScopes": ["https://www.googleapis.com/auth/documents", "https://www.googleapis.com/auth/drive"]
Create a new version of the project, and try it again.
I have removed the actual permission related to project before deploy a new version.
I'm not sure whether "https://www.googleapis.com/auth/documents" path is necessary for simple creation or edition of folders/files. The other path string is certainly needed.

Google Drive watching for new files

I'm considering using Google Drive push notification in order to replace our currently pulling process.
I started playing with it, but I have 2 major problems:
Watching changes:
When watching for drive changes, I get notification with the new change id. But when I try to query it using: driveService.changes().get(changeId), I intermittently get 404. Am I doing something wrong here?
Watching files:
When watching for file changes, in case of a folder, I want to know about new files added to that folder, so I expected that when adding/removing files from this folder, the "x-goog-resource-state" will hold "add/remove" value while "x-goog-changed" will contain "children".
In reality, the "x-goog-changed" does contain "children", but the "x-goog-resource-state" is always "update", and there is no extra information about the added/deleted file.
Regarding deleted files, I know can get it by watching the file once I have it, but is there a way I can get updated about new files in a certain folder?
I was working on a similar project a few months ago. There are two things you can do to monitor changes on Google Drive :
Set Notification Push using : changes().watch()
Set Notification Push using : files().watch()
The 1st case sends you a request for everything that happens on the Drive you are monitoring, with very little information on what exactly has changed.
The 2nd case is less 'spamming', and you get to decide which folder to monitor.
However the tags on the change type are not accurate. when I was using files().watch() I tested all the use-cases, and I compared the headers of each case.
My conclusions are:
for a new file (or folder) creation inside yourfolder (yourfolder/newfile) the headers contain:
'X-Goog-Changed': 'properties'
'X-Goog-Resource-State': 'update'
which is the same when you move a file to yourfolder, or when you start following an existing file in your folder.
you get 'X-Goog-Resource-State': 'add' when you share with a user
as you can see, the header tags are not accurate/unique.
Also, note that the push-notification channel will not send you requests for files inside a folder inside yourfolder (yourfolder/folder/files). And the channel will expire at some point.
If you still have any questions, or want to know how to implement the code, let me know : )

How works chrome.fileSystem.isRestorable?

chrome.fileSystem.isRestorable is a new part of the chrome.fileSystem API and it saif if a file can be restored with its entry or not. I've made many tests but something is wrong, when I tried to do :
chrome.storage.local.get(
["recentFileId1"],
function(recent) {
chrome.fileSystem.isRestorable(
recent["recentFileId1"],
function (isRestorable){
console.log(isRestorable);
});
});
It returns me true, even if the file has been deleted of my computer. recentFileId1 seems like a real id (many numbers and the path at the end, for example FD158F2A41037D17440C025C1CA5FE08:question.txt) and the file's restoration works if the file is still on my computer. When I tried to restore the file with an id of a deleted file it just returns nothing, no error.
So I want to know : did I use this feature wrong or something? It can work if I try to restore and see what is restored (if it returns nothing the file has been deleted), but I don't want to use a hack if the API is available.
Thanks.
This function is currently only available in the dev channel of Chrome, and should be released to stable in version 31.
What you're describing sounds like a bug, please file it at http://crbug.com. We should always return true or false. What the correct behavior in this case should be is not clear.
The intent of this function is to let an app know if it should provide UI to give the user access to previously opened files. If a file is restorable, it simply means the app still has permission to access the file.
We are reserving the right to limit when files are restorable. E.g. we might have an arbitrary upper limit to how many files can be restored, or the access might timeout after a few months, or we may give the user the option of not letting apps restore any files. isRestorable lets you know if access to a previously opened file is still available.
isRestorable is not intended to give information about how accessible the file still is. Local changes can impact this - e.g. the file might be deleted or the OS access permissions changed. It might still be there but be invisible to chrome and the app due to no read access to the containing folder.
Think about a recent documents menu. This could show files which were opened and since deleted. When the app restores a deleted app it would not work and would show an error to the user. At that point the user might go to their recycle bin or git checkout and replace the file.
Or the recent documents menu could just not show files which have been deleted.
Either way your app should not rely on isRestorable as an indication of whether a file entry can be regained and successfully used, you should handle restoreFile not restoring a file and giving an error, and handle access to the file having permission problems.

Where does GM_setValue store data?

Where does GM_setValue store the data to in chrome. I've tried to determine where the data is going but couldn't figure it out. I monitored with process monitor and saw that when I stored a value chrome was updating a chrome_iwoeoiifoi2h3iofhufsdfnvdf type of file and I opened that up with an sqlite browser but the data was not there. I've looked at all the recently modified files trying to find the data but could not find it.
Latest chrome/TM.
In Tampermonkey, GM_setValue() data is stored in a LevelDB database that can be found in the User Data Directory tree.
Once in Chrome's "User Data Directory" (EG: C:\Users\USER_JOE\AppData\Local\Google\Chrome\User Data\Default\),
navigate to the Local Extension Settings\dhdgffkkebhmkfjojejmpbldmpobfkfo folder.
(gcalenpjmijncebpfijmoaglllgpjagf for the Tampermonkey Beta.)
There you will find a LevelDB database, usually named CURRENT. You can manipulate it with tools like LevelDB JSON, but external support for LevelDB currently appears to be spotty and I did not find any working tools for Windows yet (might have to compile your own).
You can also use the Chrome Storage Area Explorer extension to explore the data.
As of Tampermonkey 4.3.6, you can see an individual script's data with the Storage tab in the built-in script editor: (if the 'Storage' tab is not visible, edit Tampermonkey Settings > General Config mode > Advanced)
OLD, Pre November-ish 2015:
Before, about November 2015, data was stored in a Web SQL database in databases\chrome-extension_dhdgffkkebhmkfjojejmpbldmpobfkfo_0.
Once you have navigated to the correct folder, you will typically see two files. On my machine, they are currently just named 4 and 6. These are both SQLite files (the backend for Chrome's Web SQL implementation) and can be inspected with a SQLite viewer/utility.
The (normally) larger file, 6 on my machine, is a somewhat disturbing list of 94-thousand userscripts! I'm not sure what purpose it serves, but haven't investigated it much.
The smaller file (initially, at least), 4 on my machine, is where all the information about/for your userscripts is kept. This includes any data set by GM_setValue().
For example, if I install and run this userscript:
// ==UserScript==
// #name _GM_setValue demo
// #match https://stackoverflow.com/questions/*
// #grant GM_setValue
// ==/UserScript==
GM_setValue ('foo', 'bar');
And then I inspect the `config` table in file `4`, I will see four entries like this:
[![DB entries for sample script][8]][8]
The one you want is the `#st` row. Notice how it has the `GM_setValue` data encoded? :

Associate a help file with a library in the VBA object browser

I have a reference to the Microsoft Scripting Runtime (scrrun.dll) in one of my Access projects. If I open the object browser in VBA (by pressing F2) and choose 'Scripting' from the library dropdown it shows me all of the properties, functions, etc. for the Scripting library. If I choose one of these functions and then click on the help button (with the yellow question mark) it opens a help window with the title of 'Microsoft Visual Basic Help.'
It acts like it is unable to find the help file for this library. I can manually find the help file on my computer at the following location: "C:\Program Files (x86)\Common Files\microsoft shared\VBA\VBA6\1033\VBLR6.CHM". (Note: I have 64-bit Win 7, thus the '(x86)' in the Program Files folder name.)
I tried copying the help file to the following locations with no luck:
"C:\Windows\Help\VBLR6.CHM"
"C:\Windows\SysWOW64\VBLR6.CHM" (I believe SysWOW64 folder is the Win7 64-bit equivalent of C:\Windows\System32)
I have had this same problem with other referenced libraries as well, so I'm looking for some kind of generic solution. I'm hoping there is some way to specify a location for the help file of a particular reference, or something else along those lines.
Copy VBLR6.CHM to "C:\Program Files (x86)\Microsoft Office\Office10\1033\VBENLR98.CHM"
That's the short answer for this specific case...here's how to get there which may be useful for getting other help files associated:
Download Process Monitor (currently hosted here: http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx or do a Google search for Process Monitor)
Run Process Monitor with the following filter: 'Process Name' 'is' MSOHelp.exe 'include'
Open object browser in VBA
Choose the library (Scripting in this case)
Choose any function, property, or event in the library and click on the yellow question mark (this should open an empty window with the title Microsoft Visual Basic Help)
Go back to Process Monitor and scroll all the way to the bottom of the list; make sure the Path and Result columns are displayed
There should be dozens of 'PATH NOT FOUND' and 'NAME NOT FOUND' Results in the list. For each one of these results, there should be a corresponding Path where MSOHelp was looking for the help file. Choose any one of these and create a file with that path name. I chose to create a copy of the help file from its original location to the new spot and rename it to match what MSOHelp was looking for.
My best guess is that the scrrun.dll contains the name of the help file and over the years the dll stayed the same but the help file was renamed, modified, etc.