How do I get Windows shortcut "Starts In" behaviour when double-clicking on files? - windows

I have a type of data file associated with my program. I can run my program by clicking on a shortcut, or by double-clicking on the data file. Standard Windows stuff.
However, I need to be able to set the Starts In folder to a specific folder. Everything is fine when I use the shortcut (because that has a Starts In parameter), but when I double-click on a data file, the Starts In defaults to the local folder of the data file, which is not what I want.
To be more specific, I'm using a network dongle protection system (Safenet SHK) that requires an XML file to be in the Starts In folder before the protection shell allows my code to be run, so I can't just change the folder in my program, because it hasn't run yet.
What can I do?

You could create a launcher application. This application would do nothing but set the working directory and then start the real application and pass in the name of the file the user is trying to open. Your application shortcut can point to your main application, but the file associations you create would use the launcher.

Related

Create executable to run a shortcut? Similar to a .bat file but a .exe?

I have a keyboard with 6 keys I can assign pretty much anything to, including opening apps.
I want to be able to open Spotify with one of these keys, but I have to have to link a .exe to to the key - no other file type will work.
I have Spotify downloaded from the Windows Store, so it's stuck under the WindowsApp folder in Program Files, which means I can't access it directly. Even if I create a shortcut and put it on the desktop, it's not an .exe, it a .lnk.
I'm wondering if there's a way to create a .exe file that will run the Spotify shortcut that I have on my desktop, or any app at all.
I know it sounds redundant - creating a .exe to run a .exe - but I can't access the WindowsApp folder to directly link it to my keyboard. I know a batch file would work, but I can't link a .bat to my keyboard, only .exe.
I don't have experience creating executables, so I don't even know where to start and I haven't been able to find anything online.
If you wish to try this yourself, you will need to:
install a compiler
write the code
use the compiler to create an executable
While this might sound complicated for somebody without experience, in this case is not that hard.
Here is how you can do it using the very simple PureBasic compiler:
download and install the PureBasic compiler from this website
https://www.purebasic.com/download.php
(the demo version is fine, it will do the job)
choose [PureBasic-Demo.zip (x64 - 64 bit)]
launch the PureBasic IDE and write this code:
in this example I'm making an executable which will launch Sublime Text, so change the path to your Spotify executable
```
; // make this a console program
OpenConsole()
; // specify path to another executable
pathToExecutable$ = "C:\Program Files\Sublime Text 3\sublime_text.exe"
; // use RunProgram to launch another executable
x = RunProgram(pathToExecutable$)
```
after you enter the code, click on File menu at the top, then click on Save As..., you will be prompted for a name for your source code file.
select a location, for example your Desktop then, enter a name for the file, for example proxy. (this will create a proxy.pb file)
last step, create the proxy.exe executable
click on Compiler menu, then click on Create Executable...
select location (again I recommend your Desktop), then enter a name for the executable, again for example proxy and then click on Save (this will create proxy.exe on your Desktop)
You can move your new created executable anywhere, it's portable.
Good luck!
This is Stack Overflow where you can do it yourself so here is how.
Download a BAT to EXE convertor from here or here.
Make a batch file to start the program of your choice. (Code would look like the following)
#start "" "C:\users\JimithyJones\Desktop\Spotify.exe" && exit
Convert it to an EXE with one of the previous programs. WARNING! Sometimes they are detected as malicious files because batch files have the capability to do harm to your computor.
Assign the new EXE to your hotkeys.

How can I open a Microsoft Access Database file with an .exe?

I have been working on creating a pretty advanced GUI enabled database in Microsoft Access and am now in the implementation phase of my project.
My dream is to make an .exe file that will point to the actual .accdb database file (which will be hidden) as I cannot change the icon of the .accdb but will be able to modify the .exe's icon thus giving my implementation a more professional feel.
I'd prefer not to just create a shortcut to the .accdb and change that icon.
Through some quick digging, my plan was to create a .bat file that opens the .accdb and then use some online ".bat to .exe" converter to then add an icon to the .exe.
I can't figure out how to create a .bat file that opens my .accdb. I've tried a variety of different things like:
start "" C:\Program Files (x86)\CompassTrack "Science Department.accdb"
and other things that dont work.
It occurred to me that a .bat to .exe approach may not be the best way to do this. I don't particularily like the brief command prompt window appearance and would be open to any suggestions as to how to get a nice looking .exe file to open my .accdb.
If the best way really is a .bat file, I'd appreciate some help with the .bat file. The path to the file is C:\Program Files (x86)\CompassTrack\Science Department.accdb but for some reason every time, command prompt would return "Cannot find C:\Program "
Thanks in advance!
to change icon of an exe file using batch, look here
and to start your file use:
cd "C:\Program Files (x86)\CompassTrack"
start "" "Science Departement.accdb"
I believe you can just change the icon of your Access database. Go to Current Database (in recent versions under Office Button > Access Options) and the option is in there.
Here's a really simple C# program that you can compile into an exe very easily to if you have .NET 3.5 installed. it uses a utility called the command line compiler. You'll have to change the file path obviously.
using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
public class App
{
public static void Main(string[] args)
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = #"c:/your_file_path_goes_here/YourDB.accdb";
myProcess.Start();
}
}
You'll write the above to a text file with the extension .cs. Then create a batch file (a text file with the extension .bat) with this code.
#echo OFF
echo Compiling A File . . .
C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe /win32icon:_.ico /target:winexe /recurse:*.cs
echo.
#pause
Put these in the same dir as whatever icon you want to use, but make sure the icon is an iso file named _, as seen in the batch program. When you run the bat file, it will create the exe with the icon of your choice and it will simply launch the access database.
The feature and ability is part of the Access development system. Attempting to modify some .exe file etc. will not work.
I do suggest that you set the icon under file->options current database. It not clear why this is not working (perhaps start a new question to resolve that issue).
Keep in mind that if you deploy or change the resulting location, then you have to change the above “options” setting (manually, or by code – this much explain why your icon is not displaying – the path name cannot be relative – must be absolute.
ALSO select the box that says to use the icon for all forms and reports (this will give your application a MUCH more polished look. Since the .exe that actually runs your file is msacces.exe, then you can’t really change the application icon any other way. You see icons for the application AND ALSO forms like this "when" you set the application icon as per above:
So you WILL want to set the application icon. You then create a shortcut on your desktop. And again set the icon for that windows shortcut (it will nicely show up in the task bar with that icon).
The actual shortcut will look much like this:
"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"
"c:\RidesDev\SkiRides\ RidesXP.accde" /runtime
The above shortcut will be on a single line (space between the two lines). The above is for Access 2010, so for 2013, then the folder is office15, and for 2016, it is office16 in above.
Also NOTE very important is the /runtime. This will ensure that the access icon NEVER shows during start-up.
Also, during start-up you will often see the MS Access splash logo during start-up. E.g. this:
You can replace this splash screen by placing a .bmp (picture) file in the SAME folder as the accDE with the same name.
So in above, if I place a RidesXMP.bmp picture file, then during start-up in place of the access splash screen, you see this:
Since you likely want the forms + reports icon to be custom, then the above makes the most sense. Your approach would ONLY give you a desktop icon, not one for the task bar, forms etc.
The above will result in hiding the access splash logo during start-up, and also apply an icon to all forms etc. I don’t suggest some approach that attempts to modify some .exe or some such – that’s likely to cause issues on customers computers. And using some .exe will not give you the icon for forms and repots.

How can I open a folder with an application

I have an application that can "serialize" its state as a folder with images. This folder is called, e.g., C:\Temp\MyProject.ImageExplorer and the FileSystem consists of :
C:\Temp\MyProject.ImageExplorer\Pic1.jpeg
C:\Temp\MyProject.ImageExplorer\Pic2.jpeg
...
Can I Configure Windows Explorer in a way, that a Double Click on a folder with my .ImageExplorer "extension" does not open the folder but starts my ImageExplorer.exe with the folder name as command line argument?
Can I modify the C# .Net OpenFile Selector in a way to open these "Folders" including the Filter by extension ?
You can do it but might have issues since the file type is a folder. What I would do is basically make it a uncompressed .ZIP file, You can change the extension to what ever you want so you can associate it with your application like .IZP
You can make your application setup a registry key that associates .IZP with your application and pass the path to the file in as parameter to program.exe path/to/izp/that/user/opened
You might just have to adjust the program to handle reading a container rather than a folder.

C: drive access permission in windows 7

In matlab, I used a windows standalone application. There is a line in this application that writes a file in C:\...\...\. When I run the output exe file produced from this windows standalone application, the exe doesn't write in C:\...\...\ neither tells me that there is a security issues in that partition. All the execution does is nothing. But, when I right-click and run the exe as administrator, it runs correctly.
I want to do it without right-click and run as administrator. Are there is a command in matlab that can do that?
If you create a shortcut to your application, you can go to the Properties of the shortcut, click on Advanced in the Shortcut tab, and select "Run as administrator". That way, whenever you start the application from the shortcut it will be run as an administrator.
(Disclaimer: applications really shouldn't "foul their own nest" by writing into Program Files. This is bad design.)
Starting from Vista, unprivileged processes are not allowed to write to protected folders such as Program Files, because Program Files is designed to store code and not data. However, since this limitation has not been enforced in XP, MS has provided a backward-compatibility hack in the form of Virtual Store. Now, when a program tries to write to protected folder, its output is being redirected into a dedicated folder. This way, the program still "thinks" it writes to its usual location, while in fact it writes to an unprotected location. However, when you later check the Program Files location, you might not see the file - because it's not really there.
You can find more details here: User Account Control Data Redirection.
If you are administrator, add full control permission for your username to the destination folder. You do that by right clicking on the folder, going to properties and then security tab. Then edit and add you username with Full Control rights. Then you don;t have to run the the program as an administrator.
There is no way you can elevate a process once it is started, so Matlab cannot possibly have a command for that. Just running Matlab elevated.

In windows, can a file name extension launch a web app?

Default programs for launching a specific type of file can be configured in windows. For example, double clicking a .doc file will open that file in Word, but you can reconfigured the default program associated with the .doc extension to launch the file in any program you want.
My question is, can you set the 'default program' to be a web app, or a URL? I have a web app that exports files that can then be re-imported into the web app. I want to be able to double click on those files and have a browser window open that automatically imports that file into the web app.
Yes you can.
There is a registry entry that maps an extension to a file type. There are registry entries for the file type indicating "verbs" that can be performed for that file type. One of those entries for the verb will indicate a command line, and the command line is completely arbitrary. As long as you can specify a URL in the command line to the browser, you can make the browser open anything you want.
Here's a Microsoft reference to get you started: Verbs and File Associations

Resources