简体   繁体   English

psr.exe的32/64位问题

[英]32/64 bits Issue with psr.exe

I currently have an issue with psr.exe. 我目前有psr.exe问题。 Actually, it works perfectly with the following command : 实际上,它可以与以下命令完美配合:

  • C:\\windows\\system32\\psr.exe C:\\ windows \\ system32 \\ psr.exe
  • C:\\windows\\syswow64\\psr.exe C:\\ windows \\ syswow64 \\ psr.exe
  • psr.exe (with system32\\cmd.exe and syswow64\\cmd.exe). psr.exe(带有system32 \\ cmd.exe和syswow64 \\ cmd.exe)。

BUT, it does not work when my program (a 32 bits program running on a 64 bits windows 7) use this bat to start the application. 但是,当我的程序(在64位Windows 7上运行的32位程序)使用此bat启动应用程序时,它不起作用。 Nothing happens. 什么都没发生。 My programm can open a notepad from a bat files, or execute whatever you want, but it does not work with psr.exe. 我的程序可以从bat文件中打开记事本,或执行所需的任何操作,但不适用于psr.exe。

Can you give me some tips? 你能给我一些提示吗? Maybe it is not a 32/64 bits compatibility issue but I have other no idea about why this does not works... 也许这不是32/64位兼容性问题,但是我不知道为什么这不起作用...

EDIT : The batch file content is: C:\\windows\\system32\\psr.exe 编辑:批处理文件的内容是: C:\\windows\\system32\\psr.exe

The program running this bat is written in C, it uses this function to start it: 运行此bat的程序用C编写,它使用以下函数启动它:

CreateProcessAsUser(
    hTokenDup,
    NULL,
    "C:\\toto\\mybat.bat",
    NULL,
    NULL,
    FALSE,
    NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE,
    lpEnvironment,
    NULL,
    &sInfo,
    &ProcessInfo)

It works perfectly if the .bat file contains C:\\windows\\system32\\notepad.exe instead of C:\\windows\\system32\\psr.exe . 如果.bat文件包含C:\\windows\\system32\\notepad.exe而不是C:\\windows\\system32\\psr.exe则它可以完美工作。

If I double click on my bat files containing C:\\windows\\system32\\psr.exe from my desktop, it works perfectly, but from my C program, it does not work. 如果我从桌面上双击包含C:\\windows\\system32\\psr.exe bat文件,则它可以正常运行,但从我的C程序中,则无法运行。

(NB : My c program works with other .exe files like notepad for example) (注:我的c程序可与其他.exe文件一起使用,例如记事本)

Many thanks. 非常感谢。

Johan 约翰

If a 32-bit program running on 64-bit windows OS tries to access a file C:\\windows\\system32\\psr.exe , Windows redirects the request to file C:\\windows\\syswow64\\psr.exe . 如果在64位Windows OS上运行的32位程序尝试访问文件C:\\windows\\system32\\psr.exe ,则Windows会将请求重定向到文件C:\\windows\\syswow64\\psr.exe

To start a 64-bit system application from 32-bit environment you need to execute C:\\windows\\sysnative\\psr.exe which will be redirected to "real" C:\\windows\\system32\\psr.exe . 要从32位环境中启动64位系统应用程序,您需要执行C:\\windows\\sysnative\\psr.exe ,它将被重定向到“真实” C:\\windows\\system32\\psr.exe

To run the bat-file entirely in a 64-bit environment, execute C:\\windows\\sysnative\\cmd.exe with following parameters: /c "C:\\toto\\mybat.bat" 要完全在64位环境中运行bat文件,请使用以下参数执行C:\\windows\\sysnative\\cmd.exe/c "C:\\toto\\mybat.bat"

However, this does not appear to be a problem in your case. 但是,这对您而言似乎不是问题。

Could it be that the user you are trying to impersonate has a corrupted profile, home folder, environment, or does not have some sort of privilege required by psr.exe application? 可能是您要模拟的用户的配置文件,主文件夹,环境已损坏,或者没有psr.exe应用程序所需的某种特权?

Or maybe the app requires user profile to be loaded but you didn't load it by calling LoadUserProfile() beforehand? 还是应用程序需要加载用户配置文件,但是您没有通过预先调用LoadUserProfile()加载它?

Try testing by running your batch file like this: 尝试通过运行您的批处理文件进行测试,如下所示:

c:\windows\syswow64\runas.exe /noprofile /env /user:INSERT_USERNAME_HERE "C:\toto\mybat.bat"

Does it work? 它行得通吗? Now try removing /env and/or replacing /noprofile with /profile . 现在尝试删除/env和/或将/noprofile替换为/profile Does it now? 现在吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM