在网络浏览器之外创建 cookie(例如,使用 VBScript)

发布于 2024-12-06 02:27:43 字数 573 浏览 0 评论 0原文

这是一个非常随机的请求 - 相信我,我希望我也不必这样做。从本质上讲,客户用户正在使用一个与我们推出的其他技术配合使用的网站。我们已经用尽了所有其他途径来让事情正常工作,所以我现在处于解决方法/回避领域。

我在网站上找到了一个确实可以使事情发挥作用的选项。然而,我们不希望指导用户自己配置它(不幸的是,这也是不必要的复杂)。

因此,我想要/需要做的是在计算机登录时设置 cookie。 cookie 包含的所有内容都是“0:-”,这只是禁用了我们需要禁用的功能。

再次,我意识到这是非常不可取的,但假设我能找到摆脱这种情况的方法,那么我就会摆脱困境。理想情况下是在 VBScript 中,但实际上任何对用户不可见的东西都是好的。

仅供参考,这是一个 Server 2008 R2 域,其中包含运行 IE8 和 IE9 的 Vista 和 Windows 7 客户端。这就是工作范围,也是我开始工作所需的一切!

我很高兴听到替代建议,但最终结果是我们希望自动为用户禁用此网站功能。

非常感谢任何帮助。

编辑:我已经标记了 C#,因为我也相当熟悉它(来自系统管理员 PoV)

谢谢,

Dan

A very random request - and trust me, I wish I didn't have to do it either. Essentially, a customers users are using a website that plays up with some other technology we roll out. We've exhausted all other routes in getting things to work properly, so I'm now in workaround / bodge territory.

I've found an option on the website which does make things work. However, it's undesirable (And needless convoluted unfortunately) for us to direct the users to configure this themselves.

Therefore, what I'd like / need to do is to set a cookie on computer logon. All the cookie contains is "0:-" which just disables the feature we need to disable.

Again, I realise this is highly undesirable but assuming I can find a way out of this, then I'll be out of the woods. Ideally in VBScript, but really anything that is invisible to the users is good.

Just for context, this is a Server 2008 R2 domain with Vista and Windows 7 Clients running IE8 and IE9. That is the scope for work and all I need to get working!

I'm happy to hear alternative suggestions, but the end result is that we want to automatically disable this websites feature for our users.

Any help gratefully received.

Edit: I've tagged C# as I'm reasonably familiar with that too (From a SysAdmin PoV)

Thanks,

Dan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷你仙 2024-12-13 02:27:43

好吧,我想我可能已经用 C# 破解了它。以下是我的代码摘录:

    [DllImport("ieframe.dll", CharSet = CharSet.Auto, SetLastError = true)]
    private static extern bool IESetProtectedModeCookie(string url, string name, string data, int flags);

    public static bool SetWinINETCookieString()
    {
      IESetProtectedModeCookie("http://url.co.uk", "name", "data=blah; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/", 0x10);
      IESetProtectedModeCookie("http://url.co.uk", "name", "data=blah; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/", 0);

     return true;
    }

似乎必须设置 cookie 两次(使用两个不同的标志)才能获得一致的行为,无论该网站之前是否被访问过。

还添加了以下几行来捕获非保护模式。这似乎涵盖了所有基础并适用于 IE9 和 IE8:

    [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
    private static extern bool InternetSetCookie(string url, string name, string data);

    InternetSetCookie("http://url.co.uk", "Name", "data=blah; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/");

Well, I think I may have cracked it in C#. Here are my code extracts:

    [DllImport("ieframe.dll", CharSet = CharSet.Auto, SetLastError = true)]
    private static extern bool IESetProtectedModeCookie(string url, string name, string data, int flags);

    public static bool SetWinINETCookieString()
    {
      IESetProtectedModeCookie("http://url.co.uk", "name", "data=blah; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/", 0x10);
      IESetProtectedModeCookie("http://url.co.uk", "name", "data=blah; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/", 0);

     return true;
    }

It seems to have to set the cookie twice (With two different flags) in order to get consistent behaviour regardless of whether the website has been visited before or not.

Added the following lines to catch non-protected mode, too. This appears to cover all bases and works on IE9 and IE8:

    [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
    private static extern bool InternetSetCookie(string url, string name, string data);

    InternetSetCookie("http://url.co.uk", "Name", "data=blah; expires = Sat,01-Jan-2012 00:00:00 GMT; path=/");
久隐师 2024-12-13 02:27:43

如果没有找到 cookie,您将无法禁用这些功能。那么,当用户打开应用程序并且还没有 cookie 时,您会禁用该功能吗?

也许为那些发送某些控制变量或访问与普通用户不同的 url 的用户创建不同的登录 url。例如,您可以通过桌面上的链接将他们定向到此网址吗?

You cannnot disable the features if no cookie one found. So when a user opens the application and doesn't have a cookie yet you disable the functionality?

Maybe make a different logon url for those users that sends some control variable or accesses a different url as opposed to the normal users. You could direct them to this url by a link on their desktop for example?

晚雾 2024-12-13 02:27:43

[更新:由于我最初的回复完全是垃圾...]

  • 一般来说,cookie 是纯文本。
  • IE cookie 的构建方式类似于 那个 [您可能想阅读这个,也是 - 因为你需要 FILETIME 值来构建你自己的 cookie]。
  • 然后,在 Win7 上,您将发现存储在 %userprofile%\AppData\Roaming\Microsoft\Windows\Cookies\Low 中的 Cookie

通过这些构建块,您现在应该能够构建适合的解决方案您的需求。

[另一个更新:您还应该看看 IE 的 index.dat(cookie(文件)注册表)和 cookie 本身的交互。也许您需要a)手动在index.dat中注册您的cookie,或者 - 如果这不起作用 - b)创建cookie文件后删除index.dat(IE将在浏览器下次启动时重建它) .]

[Update: Since my initial reply was completely rubbish...]

  • Generally speaking, cookies are plain text.
  • IE cookies are built like that [You probably want to read this, too - since you need FILETIME values to build your own cookie].
  • Then, on Win7, you'll find cookies stored in %userprofile%\AppData\Roaming\Microsoft\Windows\Cookies\Low

With these building blocks, you now should be able to build a solution that fits your needs.

[And another update: You should take also take a look at the interaction of IE's index.dat - a cookie (file) registry - and the cookie itself. Maybe you need to a) register your cookie in index.dat manually, or - if this doesn't work - b) delete index.dat after you created the cookie file (IE will rebuild it then when the browser starts the next time).]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文