使用Windows脚本宿主 [英] using Windows Script Host

查看:551
本文介绍了使用Windows脚本宿主的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Windows脚本宿主某种安装应用程序中,我创造与之开始菜单快捷方式。这个问题就来了,当我切换到64位环境(Win7旗舰版的x64 + VS2010)

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

我添加到Windows脚本宿主对象模型的参考(从C:\windows\\ 。\\syswow64\wshom.ocx),它生成的dll Interop.IWshRuntimeLibrary

I added a reference to Windows Script Host Object Model (from c:\windows\syswow64\wshom.ocx), it generated Interop.IWshRuntimeLibrary dll.

我说'使用IWshRuntimeLibrary;我的.cs文件,但是当我试图创建

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

WshShell sh = new WshShellClass(); 



它抛出一个异常:

it throws an exception:

无法加载文件或程序集Interop.IWshRuntimeLibrary,版本= 1.0.0.0,文化=中性公钥= null或它的一个依赖。试图加载格式不正确的程序。

Could not 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 load a program with an incorrect format.

我认为我会需要一个wshom的64位版本。 OCX这个工作,但我不知道我应该怎么尝试。

I assume that I would need 64-bit version of that wshom.ocx for this to work, but I don't know what should I try.

或者我就甩Windows脚本的东西,但我需要另一种方式来创建.NET应用程序的开始菜单快捷方式。

Or I'll just dump Windows Script stuff, but I need another way to create start menu shortcuts from .net application.

推荐答案

似乎.NET需要的所有组件是相同的32位或64位,不会让你随意搭配。所以,如果你的应用程序在32位工作,你应该尝试设置的编译选项(在项目属性)明确产生一个86(即32位)的应用程序(应该在32位和64运行比特)。这可能比跟踪脚本主机的64位版本的更容易。

It seems that .NET needs all assemblies to be the same 32-bit or 64-bit, and won't let you mix and match. So if you app was working in 32-bit, you should try setting the compiler options (in the project properties) to explicitly produce an "x86" (i.e., 32-bit) app (which should run on both 32-bit and 64-bit). This may be easier than tracking down a 64-bit version of the scripting host.

请注意,默认的编译器选项似乎是任何,这将运行。 .NET程序集64位当在64位操作系统和32位操作系统。

Note that the default compiler option seems to be "Any", which will run the .NET assembly as 64-bit when on a 64-bit OS, and 32-bit on 32-bit OSs.

这篇关于使用Windows脚本宿主的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆