Delphi: How to create a Windows autostart application like Skype does? - delphi

I'd like to add an option to my application similar to the Skype's option "run Skype as my computer starts".
Skype doesnt't go on the "Auto start applications" of the start menu folder, I'd like to have the same effect.
Note, one answer to this question suggets to add a key here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
but I checekd on my machine and Skype is not there, so another way is used.

Skype installs via a registry entry, but it's in HKEY_CURRENT_USER , not HKEY_LOCAL_MACHINE
This allows Skype to be installed or not on a per-user basis. Using HKLM will autostart for ALL users.
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

If you type "msconfig" into the run window and look at the startup tab you can see where "everthing" starts from in the Location column.
I don't use skype but my guess would it's in the registry in
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
You just need to add a registry entry for your app in there (and delete it if the user unticks the box)
you can use the TRegistry class to help you reading and writing to the registry.

See this question. The question is about C#, but it only involves writing a registry value. It will be easy to convert it for Delphi.

Just run msconfig and select startup tab. You'll see the applications along side the registry key used.
Oddly, when I run regedit without elevation don't see the value HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\Skype also. But if I run it elevated then the value is there (I guess that Windows is playing registry redirection).
Best

Related

Execution between docker container

I would like to know if it's possible to create a kind of communication between two docker container.
I've two docker containers, one for Firefox and another one for vscode. I'm looking for a solution to be able to open URL link from vscode in my running Firefox container(create a new tab as we have when we are selecting a link).
Don't know if it's possible to do that. Maybe by sharing some specific resource.
Thanks
I am not sure about the possibility but there are two scenarios:
Either you find a way/extension to make vscode call a browser over network
Mount the needed files/binaries as a volume from firefox container to vscode container to make it able call the firefox binary locally as usual in order to make it able to open the browser (not tested but might be done somehow) but it might not be able to open in the same session, so give it a try and let me know so i can update the answer.

Mapped drive letters immediately available?

I am using this to map a drive letter in PowerShell v2, and it works in that the drive letter shows up and is usable in Explorer.
$Network = New-Object -ComObject "Wscript.Network"
$Network.MapNetworkDrive($drive.name, $drive.value, $true)
However, if I then try to use that drive letter to do anything in Powershell, say to create a folder, I get a DriveNotFoundException. But as I said, the drive is there and usable manually. I thought I might need to wait for a bit, or refresh Explorer, or both, but doing so seems not to affect anything. However, if I turn around and rerun the script, which checks in advance to see if the drive is there, and only creates it if not, it will see the drive and not recreate, and a following task will work fine. As if perhaps the drive letter is session based?
I also tried adding
New-PSDrive -name:($drive.name -replace ':', '') -psProvider:FileSystem -root:$drive.value -scope:Global
as well, in the hopes that this would provide a session based drive, but no good.
An additional wrinkle is that the script has to be Run as Administrator, but again, if I do it as two different scripts, one to create the drive and one to use it, it works when both are Run As Administrator. It's only when both tasks are done in the one script that it fails.
One last point, I know PS 3 has a better way to handle mapped drives, but due to things beyond my control I am limited to PS v2.
I don't think what you want is possible in PowerShell v2. To have New-PSDrive create a Windows drive you need to add the parameter -Persist, which isn't available in PowerShell v2.
From the documentation:
-Persist
Creates a Windows mapped network drive. Mapped network drives are saved in Windows on the local computer. They are persistent, not session-specific, and can be viewed and managed in File Explorer and other tools.
I'd say your best option (aside from upgrading to PowerShell v3 or newer) is to use the net command:
& net use $drive.name $drive.value /persistent:yes

Granting "Local System" permissions the installation folder in Advanced Installer

I have an "Advanced Installer" project that I am trying to use to install my "TopShelf" windows service that I have built.
I found the spot in Advanced Installer to grant permissions to the installation folder, but I don't see a way to grant permissions to the "Local System" account.
Manually, this is done by going to the security option in the properties of the folder and adding a user with the same name as the computer name but ending with a $. For Example MyNiceComputer$. (Oh, and you have to select the "Computers" option in the types area.)
But there is no way to do all this in Advanced Installer. If I do make one like MyNiceComputer$, it just makes an empty entry in the security tab. (No Permissions on it, even though I setup for full control.)
Has anyone ever needed to do this with Advanced Installer?
Additional Details:
I am installing an app that runs as a windows service. (It is a console app built with TopShelf).
Our company policy is to install all our applications into a folder that looks like this:
C:\OurCompanyApps\MyApp
When I create the installer, it runs fine, but then I when I start up the Windows Service, I get the following error:
Windows could not start the MyApp service on Local Computer
Error 5: Access is denied.
But when I grant access to Local System (by giving Full Control rights to myNiceComputer$ on the MyApp folder), then this error goes away and the app runs fine. From what I read, this is because the application is running as Local System.
It seems odd that it needs full control but it does not work without it. (But as far as I can see, the contents of the folder are un-altered).
#Bogdan Mitrache seems to indicate that granting permissions to Local System is not possible via Advanced Installer. This is good to know (so I don't waste more time looking). I will probably ask my System Admins for a dedicated system account to run my service as. Not ideal, but it will serve as a work around.
So, in one of my "less finer" moments of debugging, I mixed up two different things.
There was also a file missing, (my config file). I restored that and changed the permissions at the same time. But then I forgot to go back and verify which one was the actual fix. (I know, not good debugging.)
So, the Access is denied error was due to a missing file.

How to change homepage by Registry in Edge Browser

I want to change the homepage in the Edge browser via Registry but it's encrypted and I see (Protected - It is a violation of Windows Policy to modify. See aka.ms/browserpolicy) in Registry. Please help me to edit homepage in Registry or find where it's a violation of Windows policy to modify. See aka.ms/browserpolicy
ProtectedHomepages value is not really encrypted, instead it is an obfuscated buffer which contains homepages strings and the cryptographic hash for these strings. Buffer is obfuscated using the random generated seed which is also stored as a part of the buffer. I have done some reverse engineering research and published the results here.
So, basically, reading and decrypting this value is easier than modifying due to the required crypto-hash. However, reading capability is the only required for anti-malware software. I don't know what reasons you have to modify this value, hopefully you are not writing a piece of malware...
If it is only the homepage in Edge you want to set then change the URL below to your preference and then save this as a .reg file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main]
"HomeButtonEnabled"=dword:00000001
"HomeButtonPage"="https://www.google.com/"
Currently it is not possible to change the startpage of Microsoft Edge writing string or binary value into the registry. The entry to change is "Protected - It is a violation of Windows Policy to modify. See aka.ms/browserpolicy" -> Value "ProtectedHomepages". The value is a encrypted binary value, in which the current homepage is not readable.
When you have to set a specific homepage more than one time and you want to do it with C# here a Workaround:
Set the startpage you want via UI of the Microsoft Edge browser. After Change of it restart the browser and export the registrykey named above. Open the exported file and copy the binary data into a string constant or resource in your C# Solution. In the function to write this Setting you can copy the string into a byte-Array and than writing as binary value into the registry. This entry has effect after restart of Microsoft Edge.
The same way you should use also when you want to Change the Default Search Provider. But in this case in addition to the value "ProtectedSearchScopes" one more registrykey is to use -> "OpenSearch". This key does/should exists by third Party search Providers only. This key should be deleted or does not exist if the search Provider is Bing.
Disable your computer's network interface
Launch MS Edge. The recovery page will error out
Open a new MS Edge tab
Close the MS Edge tab containing the error message
Close MS Edge
Enable your computer's network interface
Launch MS Edge
Also...
Some malware will change the Edge homepage. You can see the malicious URL in address bar, record it.
Kill Edge with Task Manager or reboot.
Edit your hosts file in c:\windows\system32\drivers\etc, from an Administrative command prompt go to that directory and type notepad hosts and hit Enter.
Add a host entry like this
127.0.0.1 bad.url (substitute the URL you recorded above for bad.url)
Save the hosts file then open Edge. This method is helpful when you are remoted in and cannot disconnect the network connection.
No need to do it in registry. You can now change the homepage via the settings in Microsoft Edge

How Can I get muitiple files selected to the same application launch from a "right click" context menu (windows explorer)

I am able to get a shell registry type context menu function to work , see below . But is there a way to tell windows to send multiple files selected to the same application , perhaps instead of %1 or %L some other parameter . What happens now is that it launches the associated application for each file in the list .
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT*\shell]
[HKEY_CLASSES_ROOT*\shell\sendtomyapp]
#="&Upload to (File*Pics)Mojo"
[HKEY_CLASSES_ROOT*\shell\sendtomyapp\command]
#="c:\Program Files\app_directory\App.exe -n \"%1\""
Is there a way to send an array of names like sys.args in python ?
My guess is to look into DDEExec instead of shell\open\command. http://msdn.microsoft.com/en-us/library/bb165967(VS.80).aspx
Seems like a superuser.com question, but I think these kind of operations require a bit of code. e.g. you write a proxy program that accepts the files, and adds them to an execution queue or batch of another program (like adding several files to a media player) I don't know if what you are looking for is supported inherently in Windows
You will need a full shell extension DLL to do what you want to do here. So the answer is programming even if the question was not.

Resources