Hi,
I've had this niggling issue from time to time. I want to create a
shortcut on the user's desktop to a website that specifically loads
Firefox even if Firefox is not the default browser.
I usually use COM as it allows very specific settings of the shortcut,
such as the Working Directory and the Target Path. However, the
following will not work for some reason:
<code>
import win32com.client
import winshell
shell = win32com.client .Dispatch('WScr ipt.Shell')
userDesktop = winshell.deskto p()
shortcut = shell.CreateSho rtCut(userDeskt op + '\\MyShortcut.l nk')
shortcut.Target path = r'"C:\Program Files\Mozilla Firefox\firefox .exe"
https:\www.myCo mpanyWebsite.co m\auth\preauth. php'
shortcut.Workin gDirectory = r'C:\Program Files\Mozilla
Firefox'
shortcut.save()
</code>
This creates the following target path (which doesn't work):
"C:\"C:\Pro gram Files\Mozilla Firefox\firefox .exe" https:
\www.myCompanyW ebsite.com\auth \preauth.php"
If I leave the website off, it works. If I leave the path to Firefox
out, it works too. Is there another method I can use other than
creating the shortcut by hand and using the shutil module?
Thank you for any ideas.
Mike 15 2510
Mike Driscoll wrote:
Hi,
I've had this niggling issue from time to time. I want to create a
shortcut on the user's desktop to a website that specifically loads
Firefox even if Firefox is not the default browser.
I usually use COM as it allows very specific settings of the shortcut,
such as the Working Directory and the Target Path. However, the
following will not work for some reason:
<code>
import win32com.client
import winshell
shell = win32com.client .Dispatch('WScr ipt.Shell')
userDesktop = winshell.deskto p()
shortcut = shell.CreateSho rtCut(userDeskt op + '\\MyShortcut.l nk')
shortcut.Target path = r'"C:\Program Files\Mozilla Firefox\firefox .exe"
https:\www.myCo mpanyWebsite.co m\auth\preauth. php'
shortcut.Workin gDirectory = r'C:\Program Files\Mozilla
Firefox'
shortcut.save()
</code>
This creates the following target path (which doesn't work):
"C:\"C:\Pro gram Files\Mozilla Firefox\firefox .exe" https:
\www.myCompanyW ebsite.com\auth \preauth.php"
If I leave the website off, it works. If I leave the path to Firefox
out, it works too. Is there another method I can use other than
creating the shortcut by hand and using the shutil module?
Thank you for any ideas.
Mike
Either you copied wrong or the problem is:
"C:\"C:\Pro gram Files...
Note the C:\ is specified twice in the string. I think it should read:
"C:\Program Files\Mozilla Firefox\firefox .exe" https:
\www.myCompanyW ebsite.com\auth \preauth.php"
-Larry
On May 15, 2:03 pm, Larry Bates <larry.ba...@we bsafe.com`wrote :
Mike Driscoll wrote:
Hi,
I've had this niggling issue from time to time. I want to create a
shortcut on the user's desktop to a website that specifically loads
Firefox even if Firefox is not the default browser.
I usually use COM as it allows very specific settings of the shortcut,
such as the Working Directory and the Target Path. However, the
following will not work for some reason:
<code>
import win32com.client
import winshell
shell = win32com.client .Dispatch('WScr ipt.Shell')
userDesktop = winshell.deskto p()
shortcut = shell.CreateSho rtCut(userDeskt op + '\\MyShortcut.l nk')
shortcut.Target path = r'"C:\Program Files\Mozilla Firefox\firefox .exe"
https:\www.myCo mpanyWebsite.co m\auth\preauth. php'
shortcut.Workin gDirectory = r'C:\Program Files\Mozilla
Firefox'
shortcut.save()
</code>
This creates the following target path (which doesn't work):
"C:\"C:\Pro gram Files\Mozilla Firefox\firefox .exe" https:
\www.myCompanyW ebsite.com\auth \preauth.php"
If I leave the website off, it works. If I leave the path to Firefox
out, it works too. Is there another method I can use other than
creating the shortcut by hand and using the shutil module?
Thank you for any ideas.
Mike
Either you copied wrong or the problem is:
"C:\"C:\Pro gram Files...
Note the C:\ is specified twice in the string. I think it should read:
"C:\Program Files\Mozilla Firefox\firefox .exe" https:
\www.myCompanyW ebsite.com\auth \preauth.php"
-Larry
Yeah, I know that it's in there twice and that that is the problem.
But I'm not causing that extra C:\. I run it exactly as above and that
is what I get for the output. I think it's the COM object. Maybe I
better just re-post this to the PyWin32 list...
Thanks,
Mike
En Thu, 15 May 2008 12:13:56 -0300, Mike Driscoll <ky******@gmail .com>
escribió:
I've had this niggling issue from time to time. I want to create a
shortcut on the user's desktop to a website that specifically loads
Firefox even if Firefox is not the default browser.
I usually use COM as it allows very specific settings of the shortcut,
such as the Working Directory and the Target Path. However, the
following will not work for some reason:
Try this different approach, using the IShellLink interface: http://aspn.activestate.com/ASPN/doc...ell_Links.html
--
Gabriel Genellina
On May 15, 5:13*pm, Mike Driscoll <kyoso...@gmail .comwrote:
Hi,
I've had this niggling issue from time to time. I want to create a
shortcut on the user's desktop to a website that specifically loads
Firefox even if Firefox is not the default browser.
I usually use COM as it allows very specific settings of the shortcut,
such as the Working Directory and the Target Path. However, the
following will not work for some reason:
<code>
import win32com.client
import winshell
shell = win32com.client .Dispatch('WScr ipt.Shell')
userDesktop = winshell.deskto p()
shortcut = shell.CreateSho rtCut(userDeskt op + '\\MyShortcut.l nk')
shortcut.Target path = r'"C:\Program Files\Mozilla Firefox\firefox .exe"
https:\www.myCo mpanyWebsite.co m\auth\preauth. php'
shortcut.Workin gDirectory = r'C:\Program Files\Mozilla
Firefox'
shortcut.save()
</code>
This creates the following target path (which doesn't work):
"C:\"C:\Pro gram Files\Mozilla Firefox\firefox .exe" https:
\www.myCompanyW ebsite.com\auth \preauth.php"
If I leave the website off, it works. If I leave the path to Firefox
out, it works too. Is there another method I can use other than
creating the shortcut by hand and using the shutil module?
Thank you for any ideas.
Mike
Don't set arguments in the path.
shortcut = shell.CreateSho rtCut(userDeskt op + '\\MyShortcut.l nk')
shortcut.Target Path = r'Program Files\Mozilla Firefox\firefox .exe'
shortcut.Argume nts = r'https:\ www.myCompanyWebsite.com\auth
\preauth.php'
shortcut.Workin gDirectory = r'C:\Program Files\Mozilla Firefox'
shortcut.save()
Mike Driscoll wrote:
Hi,
I've had this niggling issue from time to time. I want to
create a shortcut on the user's desktop to a website that
specifically loads Firefox even if Firefox is not the default
browser.
I usually use COM as it allows very specific settings of the
shortcut, such as the Working Directory and the Target Path.
However, the following will not work for some reason:
<code>
import win32com.client
import winshell
shell = win32com.client .Dispatch('WScr ipt.Shell')
userDesktop = winshell.deskto p()
shortcut = shell.CreateSho rtCut(userDeskt op +
'\\MyShortcut.l nk') shortcut.Target path = r'"C:\Program
Files\Mozilla Firefox\firefox .exe"
https:\www.myCo mpanyWebsite.co m\auth\preauth. php'
shortcut.Workin gDirectory = r'C:\Program Files\Mozilla Firefox'
shortcut.save()
</code>
This creates the following target path (which doesn't work):
"C:\"C:\Pro gram Files\Mozilla Firefox\firefox .exe" https:
\www.myCompanyW ebsite.com\auth \preauth.php"
If I leave the website off, it works. If I leave the path to
Firefox out, it works too. Is there another method I can use
other than creating the shortcut by hand and using the shutil
module?
Thank you for any ideas.
I see four problems:
1) you should not hardcode the backslashes ('\'), instead use
os.sep for it.
2) In URIs there are no backslashes, only forward slashes. You
coded
https:\...
which is _WRONG_. URIs are <protocoll>://<host>/<resource>, where
for some protocolls <hostis empty (file protocoll e.g.).
3) You assume, that Firefox is always installed at C:\Program
Files\Mozilla Firefox\firefox .exe
However the path largely differs from system to system. On *nix
systems you normally have all programs in $PATH, so a non full
qualified path would be sufficient. On Windows this works, too,
_IF_ the installation directory of the to be used application
get's added to the PATH environment variable.
Wolfgang Draxinger
--
E-Mail address works, Jabber: he******@jabber .org, ICQ: 134682867
Wolfgang Draxinger wrote:
1) you should not hardcode the backslashes ('\'), instead use
os.sep for it.
With respect, the OP is creating a Windows desktop shortcut.
Unless Microsoft suddenly decide to change their use of the
backslash, I suggest that this is a needless generalisation.
3) You assume, that Firefox is always installed at C:\Program
Files\Mozilla Firefox\firefox .exe
However the path largely differs from system to system.
This is broadly true. However, it's fairly clear from the
phrase "the user's desktop" that the OP is working in some
kind of corporate environment where he can be fairly sure
where Firefox is installed by policy. In addition, it's not so
easy to find its path if it's not in the default place since apps
very rarely add their location to the system PATH these days
(and Firefox certainly doesn't). You could scan the registry for
its App Paths entry in the registry but I don't know if any other
way if it's not the default browser (which it's clear from the
original post it may not be).
Sorry to sound a bit negative, but I felt that a couple of your points,
while valid, were not altogether helpful to the situation the OP was in.
TJG
Wolfgang Draxinger wrote:
1) you should not hardcode the backslashes ('\'), instead use
os.sep for it.
With respect, the OP is creating a Windows desktop shortcut.
Unless Microsoft suddenly decide to change their use of the
backslash, I suggest that this is a needless generalisation.
3) You assume, that Firefox is always installed at C:\Program
Files\Mozilla Firefox\firefox .exe
However the path largely differs from system to system.
This is broadly true. However, it's fairly clear from the
phrase "the user's desktop" that the OP is working in some
kind of corporate environment where he can be fairly sure
where Firefox is installed by policy. In addition, it's not so
easy to find its path if it's not in the default place since apps
very rarely add their location to the system PATH these days
(and Firefox certainly doesn't). You could scan the registry for
its App Paths entry in the registry but I don't know if any other
way if it's not the default browser (which it's clear from the
original post it may not be).
Sorry to sound a bit negative, but I felt that a couple of your points,
while valid, were not altogether helpful to the situation the OP was in.
TJG
Mike Driscoll wrote:
Ah. I was unaware of the Arguments parameter. That works quite well.
Where does one find this information anyway? I think I found mine from
bits and pieces scattered in various tutorials.
The canonical place would be: http://msdn.microsoft.com/en-us/libr...50(VS.85).aspx
TJG
Tim Golden <ma**@timgolden .me.ukwrote:
>3) You assume, that Firefox is always installed at C:\Program Files\Mozill a Firefox\firefox .exe However the path largely differs from system to system.
This is broadly true. However, it's fairly clear from the
phrase "the user's desktop" that the OP is working in some
kind of corporate environment where he can be fairly sure
where Firefox is installed by policy. In addition, it's not so
easy to find its path if it's not in the default place since apps
very rarely add their location to the system PATH these days
(and Firefox certainly doesn't). You could scan the registry for
its App Paths entry in the registry but I don't know if any other
way if it's not the default browser (which it's clear from the
original post it may not be).
It's not too hard to get the required command line from the registry:
import _winreg
print _winreg.QueryVa lue(_winreg.HKE Y_CLASSES_ROOT,
'FirefoxURL\she ll\open\command ')
and of course it throws an exception if firefox isn't installed.
Then just replace %1 with the url to get the actual command you need.
--
Duncan Booth http://kupuguy.blogspot.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Club-B42 |
last post by:
i've compiled my programm using command "python setup.py py2exe >1"
python script works fine, but .exe version fails with
=====================================================================
D:\\Scripts\B-4-2\la2luncher\dist>la2launcher.exe
Traceback (most recent call last):
File "la2launcher.py", line 9, in ?
File "config.pyc", line 11, in ?
File "config.pyc", line 8, in u
LookupError: no codec search functions registered: can't find...
|
by: ×™×•× ×™ גולדברג |
last post by:
Hi,
While trying to create new directory i recieve the following error
message:
"System.IO.DirectoryNotFoundException: Could not find a part of the path
"\\premfs16\sites".
The path exists, even when i check the path
with the code: Directory.Exists(...) the result is true.
Here is the code:
http://www.adeo.co.il/test.aspx
|
by: jemmaq99 |
last post by:
Using Visual Studio .NET 2003 I've tried to add a COM reference
to a Windows Form project via the Add Reference dialog (specifically
the Active DS Type Library) but always get the error message:
"A reference to 'Active DS Type Library' could not be added. The
type library wrapper tool 'tlbimp' cannot be found on this system.
Please re-install Visual Studio."
This occurs regardless of the actual tlb or dll selected and happens
on...
|
by: Medora Schauer |
last post by:
I've installed 7.4.2 on a PowerPC system running linux 2.4.13. When I
try to run initdb to create to create the database cluster I get the
following:
$ initdb -D $PGDATA
The files belonging to this database system will be owned by user
"thebox".
|
by: tech tech |
last post by:
Hello All,
I installed postgresql 7.3.4 on HPUX PA in /usr/local/pgsql and put the libraries in
/usr/local/pgsql/lib/LIB_new. During the initialization( initdb), it loads libraries (language) from
/usr/local/pgsql/lib. In postgresql version 7.3.1, libraries are not loaded and no such problem during initdb.
I had the following problem:
$ initdb -D /var/pgsql
The files belonging to this database system will be owned by user "postgres".
| |
by: Dany |
last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers.
Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses.
This can be easily verified:
Implement the following in a web service method (just raises a SOAPException with a...
|
by: ABC |
last post by:
How to add a underscore to indicate users what is the shorcut key of Button?
Under Winform, our can add & symbol on label to indicate what is the
shortkey of button, in ASP.NET, how should I to do that?
|
by: Chizl |
last post by:
I'm building a web server and having some issues with the
TCPListener.Start(BackLog). It doesn't seem to do as expected. I'm using
MS Web Stress Tool to test against my web server and when I see 200
connections at once to it, and I'm seeing 2/3 of the sockets as socket
errors.. They never get into my code, so it has to be failing on the
connection side.. Backlog is the only thing I can think could be the
problem. ...
|
by: Gazi |
last post by:
Hello!
I have a program with writing by .Net
it is a personal order program.
there is a database with access and this program binds it.
First it wants to username and password from user (All users have)
Then The Program looks his Position and Department from table.
if The Personal works in Ordering Department or His Position is Manager,he can see all orders and can accept or decline.
But if he doesnt work there or isnt Manager,he can see...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |