473,490 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HELP! - Calling Windows Scripting Host from C# to Create Shortcuts

G$
I'm trying to write some C# code to call the Windows Scripting Host (WSH) to
create shortcuts, but I'm having problems.

First, I referenced Windows Script Host Object Model. Then, I wrote the
code:

IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
// Neither one of the next two lines work
string sAllUsersDesktop =
shell.SpecialFolders.Item("AllUsersDesktop").ToStr ing();
string sAllUsersDesktop = shell.SpecialFolders("AllUsersDesktop");

All I'm trying to do is get the AllUsersDesktop special folder, but the code
above won't even compile. I get the following errors:

The best overloaded method match for
'IWshRuntimeLibrary.IWshCollection.Item(ref object)' has some invalid
arguments
Argument '1': cannot convert from 'string' to 'ref object'
'IWshRuntimeLibrary.IWshShell3.SpecialFolders' denotes a 'property' where a
'method' was expected
What am I doing wrong with the WSH code?

Or, is there a better way of creating shortcuts in C# code (they'll need to
be created to AllUsersDesktop or AllUsersStartMenu)?

Thanks.

Nov 16 '05 #1
1 8118
"G$" <gd**@nospam.com> wrote in
news:#7**************@tk2msftngp13.phx.gbl:
I'm trying to write some C# code to call the Windows Scripting
Host (WSH) to create shortcuts, but I'm having problems.

First, I referenced Windows Script Host Object Model. Then, I
wrote the code:

IWshRuntimeLibrary.WshShell shell = new
IWshRuntimeLibrary.WshShell(); // Neither one of the next two
lines work string sAllUsersDesktop =
shell.SpecialFolders.Item("AllUsersDesktop").ToStr ing();
string sAllUsersDesktop =
shell.SpecialFolders("AllUsersDesktop");

All I'm trying to do is get the AllUsersDesktop special folder,
but the code above won't even compile. I get the following
errors:

The best overloaded method match for
'IWshRuntimeLibrary.IWshCollection.Item(ref object)' has some
invalid arguments
Argument '1': cannot convert from 'string' to 'ref object'
'IWshRuntimeLibrary.IWshShell3.SpecialFolders' denotes a
'property' where a 'method' was expected
What am I doing wrong with the WSH code?

Or, is there a better way of creating shortcuts in C# code
(they'll need to be created to AllUsersDesktop or
AllUsersStartMenu)?

A C# example:

http://www.vbaccelerator.com/home/NE...ell_Projects/C
reating_and_Modifying_Shortcuts/article.asp

or

http://tinyurl.com/3rztd

A VB.Net example:
http://www.developerfusion.com/show/245/
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
6482
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
9
4370
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with...
4
3318
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to...
6
4298
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
6
2982
by: d.warnermurray | last post by:
I am doing a project for school that involves creating help files for a html authoring tool. If you could help me with answers to some questions it would really help. 1. What tasks do you expect...
3
3316
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
4
2601
by: dixie | last post by:
Help, I'm really out of my depth here (not unusual I hear you say :-). I have just installed HTML Help in an application. I told it in the Project Properties the path to the help file. I then...
10
3322
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
1
6110
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
0
2842
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application...
0
7112
marktang
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,...
0
6974
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...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6852
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...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
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,...
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.