I am looking for a way to create a Powershell script that will allow me to open DB Browser for SQLite ("C:\Program Files\DB Browser for SQLite\DB Browser for SQLite.exe") and upon opening, load a file (C:\Users\XXXXX\AppData\Roaming\AirHauler2XP\Company\Atlas Airlines25045 PM.db) in order for me to edit. Any help would be great (if possible).
Please see the documentation: https://github.com/sqlitebrowser/sqlitebrowser/wiki/Command-Line-Interface#examples
According to that, it should be:
"C:\Program Files\DB Browser for SQLite\sqlitebrowser" "C:\Users\XXXXX\AppData\Roaming\AirHauler2XP\Company\Atlas Airlines25045 PM.db"
#ChristianBaumann is OK, and it will work from command prompt. But for powershell this will fail. You need to use & to run it:
& "C:\Program Files\DB Browser for SQLite\sqlitebrowser.exe" "C:\Users\XXXXX\AppData\Roaming\AirHauler2XP\Company\Atlas Airlines25045 PM.db"
I would add it to the path one way or another.
$env:path += ';C:\Program Files\DB Browser for SQLite'
cd AppData\Roaming\AirHauler2XP\Company
sqlitebrowser '.\Atlas Airlines25045 PM.db' # tab completion on the filename
I made a batch file that receives one of its parameters from right-clicking on a file and sending it to my batch file.
The problem is that it crashes if the path has a space in it.
For example, a file in C:\temp\CarRide works, but a file in C:\temp\Car Ride doesn't work. The cmd window flashes and immediately closes.
I tried putting a pause as the first line in the batch file, and it didn't event get to that, so I'm pretty sure the problem is the way Send To handles the path.
Got any ideas?
Use quotes when there is a space in the Path C:\temp\CarRide vs. "C:\temp\Car Ride", otherwise the path is parsed as two arguments. In your case the first the right clicked file takes the first argument %1 so set input to "%1"
I already know that to open a webpage with the default browser you use:
start www.google.com. However, I'm trying to open a URL that contains a '&' in it for example:
https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world
If I use:
start https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world
It will not work because there is a &
& is a special character in bash, so if the URL contains a special character you just have to do it like this:
start "" "your url"
You have to escape the Ampersand (&) character with the ^ character in every occurrence of it.
start https://www.google.dz/?gws_rd=cr,ssl^&ei=rXc_WYq3Msy2abGXpugH#safe=off^&q=hello+world
Powershell
By passing through powershell : powershell Start-Process <browser> <URL>.
If you don't specify browser, then URL is open in your default browser. Mine is Google Chrome, so i have added chrome. For internet explorer, it will be iexplorer and for Mozilla Firefox, this is firefox.
Examples from a CMD prompt :
powershell Start-Process chrome http://google.com/
or a little bit shorter :
powershell Start-Process http://google.com/
or even more shorter :
powershell start http://google.com
However, in your case, type in the one hand powershell command to goto powershell prompt. In the other hand, just type one of the following command line by specifying URL with "" in order to dodge the & effect as explained by jgmh above :
start "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
or by chosing a specific browser such as firefox :
start firefox "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
or else :
[System.Diagnostics.Process]::Start("firefox.exe","https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world")
Finally, type exit in order to quit the powershell prompt.
CMD
Using start command only
idris19's method is really handy !
This command line can also help you because you are able to indicate your browser : start <browser> <URL>.
As said before, URL is open in your default browser if none is specified.
For instance :
start http://google.com
or
start chrome http://google.com
But, in your case, don't forget to add "" to avoid & issue and mention your browser to not run URL in another cmd window :
start chrome "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
You can add -incognito flag to goto an incognito browser if necessary :
start chrome "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world" -incognito
Using windows explorer
Furthermore, you can use windows explorer as following : explorer <URL>.
It always will open your URL in the default browser.
Example :
explorer http://google.com
As previously mentioned, don't forget the double quotes in your case due to & special character :
explorer "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
Note : Tested on Windows 10 64bits.
P.S : Please, don't hesitate to edit my answer because i probably made grammatical mistakes due to my low english level. Thanks !
Best regards :-)
You can use URL shorteners.
For your link:
start [created link]
If you have Linux you can try using these command
$links http://google.com
or
$elinks http://google.com/
First provide the full path to the browser application file and then the complete link like this:
start "C:\Path\To\Browser.exe" "http://WebsiteURL.com"
Try one of these command lines:
powershell -command "start 'https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world'"
or
start "" "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
or even this one:
explorer "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
When I tried the same, it worked for me only by typing :
C:\start https://www.google.dz/?ws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world
in the Command Prompt.
You can do it using start chrome -u url here.
As I write bat file very infrequently, every time I write a new one gets me a new problem.
I have a bat file that is suppose to open a txt file and open an URL (which is a concatenated string, using current date), something like:
#echo off
notepad "C:\Users\username\somefile.txt"
start chrome "https://domain.com/%DATE%?some=parameters"
The text file opens fine and then nothing happens - console window gets stuck, not responding to ctrl-C. Apparently batch is suspended waiting for the notepad part to complete, because when I close the txt file window chrome opens the URL.
I tried < nul, > nul for the notepad part, but to no avail. What am I doing wrong?
If I see this correctly, you just need to use start with notepad also. It starts programs in another process so the script can continue.
#echo off
start notepad "C:\Users\username\somefile.txt"
start chrome "https://domain.com/%DATE%?some=parameters"
I have an extremely simply batch file, which has previously worked for me but no longer will.
start /wait steamcmd +login anonymous +force_install_dir C:\Games\CSGOServer\TEST
pause
For some reason I get the following error upon running the file:
http://imgur.com/Xd8di1Y (sorry, not enough rep to enbed with html)
Any ideas why start will not work given that it is clearly an accepted command? I did notice the strange characters in front of this but cannot really tell where these would come from.
Thanks in advance.
Damon
Looks like someone saved that batch file in UTF-8 format. Open the file with Notepad and click File → Save As.... Change the field Encoding to "ANSI" and click Save. Confirm that you want to replace the file.