G
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").ToString();
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.
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").ToString();
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.