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

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.

Related

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 to Launch a Metro App from Microsoft Access VBA on Windows 10 Computer

I have a situation in which I wanted to utilize the camera app in Windows 10 from my Microsoft Access program. Normally I could just send a command to execute the program's executable, but with the metro app there is no straightforward executable.
The basic code I use is this:
Shell """" & PthToExe & """", vbNormalFocus
PthToExe is the path name for the executable.
I looked around a decent bit, but was unable to find any simple solutions and ended up coming up with my own. My solution is to make a shortcut link to the camera application and then to launch the link.
In order to make a shortcut link in Windows 10, you can click on the start button, go to "All Apps", find the app you want (in my case "Camera"), and then click and drag it to the desktop.
Now that you have a shortcut, you can launch the shortcut from a command line. (So my shortcut doesn't clutter up my desktop, I dragged it off my desktop and into a folder on the "C" drive.)
Type the path into a command prompt like this and hit enter to test launching your app: C:\GJ\Camera.lnk
So that solves the problem if you wanted to launch from a command line. For some reason, though, Access would not accept that command. The way I got around it was I put the command in a batch file (Edit: Alternatively, see HansUp's comment). To do that, you just need to open notepad, type in the same thing you typed in the command prompt, save the note pad document, and then rename the document to have a .bat extension.
You can then execute the .bat file from Microsoft Access as follows:
Shell "C:\GJ\OpenCamera.bat", vbMinimizedNoFocus
Note that normally, I use vbNormalFocus when running the shell command, but in this case, it is desirable not to see the little command prompt open before the actual program opens.

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

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.

How to change the path for "run command" "notepad"?

Where is in the registry the path executed when I run the "notepad" command in windows "Start->run command" interface? I want to change it for notepad++ (it is required so, although could look not really good)
If you are like me you use windows run command all the time. I hate using the mouse to point and click a shortcut on the start menu. WIN-R are probably the two most over used keys on my keyboard. After thinking about if awhile I hunted down how the run command works. It turns out that it makes a call to ShellExecute, which I guess is not too surprising. The next thing I wanted to find out was exactly how the commands are resolved. The following is an ordered list of how they are resolved ([1]):
The current working directory
The Windows directory (no subdirectories are searched)
The Windows\System32 directory
Directories listed in the PATH environment variable
The App Paths registry key
Naturally the next thing I wanted to do was customize existing commands or add new commands so I do not have to type as much (standard lazy approach). After examining my options which were to put the executable in one of those paths (since it only locates executables and not shortcuts), modify the path environment variable or add a key to App Paths. The App Paths option seems to be the easiest and most flexible to me. Here is a layout of what you need to do to add an App Paths entry ([1]):
HKEY_LOCAL_MACHINE-->
SOFTWARE-->
Microsoft-->
Windows-->
CurrentVersion==>
App Paths-->
file.exe-->
(Default) = The fully-qualified path and file name
Path = A semicolon-separated list of directories
DropTarget = {CLSID}
Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system. I cannot guarantee that problems resulting from modifications to the registry can be solved. Use the information provided at your own risk.
The minimum needed to add a new entry is to add the key file.exe where file is the string you want to type into the run command and to add the Default entry which is the fully-qualified path to the file you want to execute. Note that even it the file you are going to reference isn't an exe file you still need to put the .exe on the key. Here is a sample registry file that I created to add a shorter keyword for Internet Explorer:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths\ie.exe] #="C:\Program Files\Internet Explorer\iexplore.exe"
After entering that entry into the registry I can simply type “ie” at
the run command to open internet explorer.
Here is a list of some common commands I use at the run command:
cmd – Command prompt winword – Microsoft Word excel – Microsoft Excel
outlook – Microsoft Outlook iexplore – Internet Explorer firefox –
Mozilla Firefox notepad – Notepad compmgmt.msc – Computer Management
Console control appwiz.cpl – Add/Remove programs dialog mstsc –
Microsoft Terminal Service Client regedit – Registry Editor
…
If there is some program that I find myself using all the time I figure out what the run command is for it and if there is not a short easy one I add one to my App Paths as described above. Does anyone else have some other common run commands they use?

Arbitrary .cmd script as screensaver in Windows 7 / XP

I have a fullscreen OpenGL application, written in Scala. It is supposed to being launched as .cmd file that sets up classpath (some .class files, some of them are third-party libraries and optionally in .jars) and runs JVM with the right parameters. I'm wondering, is there an easy way to use this .cmd file as Windows screensaver? (without usual screensaver preview and settings dialog, they are not needed there) I guess I need to register the application somewhere? Is there any restriction on what file type it must be?
You can install a screensaver by doing as #Kevin suggested and right click the file and install (provided that this is a .scr file). Or you can copy the file straight to C:\Windows or sometimes C:\Windows\system32.
However, unless the file is a valid screensaver then it won't show up in the list of screensavers when you choose which one you want, so I think you are out of luck.
Unless you created your own screensaver, and then you might be able to launch the file from one of the events it has.

Resources