Using Windows Script Host

I am using a windows script host for some kind of installer application and I am creating shortcuts in the start menu with it. This problem arose when I switched to x64 environment (win7 ultimate x64 + vs2010)

I added a link to the Windows script Host Object Model (from c: \ windows \ syswow64 \ wshom.ocx), it generated the Interop.IWshRuntimeLibrary DLL.

I added 'using IWshRuntimeLibrary;' to my .cs files, but when I tried to create

WshShell sh = new WshShellClass(); 

it throws an exception:

Failed to load file or assembly 'Interop.IWshRuntimeLibrary, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null' or one of its dependencies. An attempt was made to download a program with the wrong format.

I assume that for this I will need a 64-bit version of this wshom.ocx, but I do not know what I should try.

Or, I just delete the contents of the Windows script, but I need another way to create start menu shortcuts from the .net application.

+6
c # interop windows-scripting
source share
1 answer

It seems like .NET requires all assemblies to be the same 32-bit or 64-bit and not allow you to mix and match. Therefore, if the application runs in 32-bit mode, you should try to set the compiler options (in the project properties) to explicitly create the "x86" application (that is, 32-bit) (which should work on both 32-bit and 64 -Little). This may be easier than tracking the 64-bit version of the script node.

Note that the default compiler setting is β€œAny,” which will run the .NET assembly as 64-bit when on a 64-bit OS and 32-bit on a 32-bit OS.

+6
source share

All Articles