我们的应用程序需要安装HASP SRM设备驱动程序才能安装和运行我们的驱动程序.
目前,只有他们的5.50驱动程序在所有测试平台上一致地工作(他们的5.75(官方)和5.86(beta)驱动程序在测试的大约三分之一的计算机中崩溃).
因此,他们的5.50驱动程序是好的,当前可用的任何其他东西都被破坏,并且5.50驱动程序拒绝在Vista和Windows 7下加载.但是,如果我将exe的属性设置为"XP兼容模式",那么他们的5.50驱动程序安装并成功运行.
我在Windows 7下的注册表中挖了一下,我发现当我要求兼容模式时至少有一个条目:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\
full-path REG_SZ WINXPSP3
Run Code Online (Sandbox Code Playgroud)
在尝试启动5.50驱动程序安装程序之前,我应该能够从安装程序添加该密钥.
问题:
我正在尝试在Windows 7中的新环境下从Windows XP编译遗留代码.它在运行时编译但失败.
CreateProcess()返回0,GetLastError()返回2,代表ERROR_FILE_NOT_FOUND
这是我对CreateProcess的调用
STARTUPINFO StartInfo;
memset(&StartInfo, 0, sizeof(StartInfo));
wcsncpy(astrCommandLine, L"TFTP", MAX_OSCOMMANDLINE_SZ-1);
BOOL bFuncRetn = CreateProcess(NULL,
astrCommandLine, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
NULL, // handles are inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&StartInfo, // STARTUPINFO pointer
&m_ProcInfo ); // receives PROCESS_INFORMATION
Run Code Online (Sandbox Code Playgroud)
现在为了奇怪:当我运行calc而不是tftp时,calc会弹出.我可以从命令提示符中的任何位置执行命令行中的任何内容,因此它告诉我%PATH%到c:\ windows\system32已知且工作正常.
我试图用ansi字符串强制CreateProcessA,但我得到了相同的结果.我也尝试过调试和发布配置以及命令行.
任何的想法?
编辑:calc.exe和tftp.exe都位于系统路径中的c:\ windows\system32中.
运行"c:\ windows\system32\tftp"不起作用
tl; dr
我试图了解通过双击可执行文件与通过终端或CreateProcess在Windows 10中以编程方式运行直接运行程序的区别。
长版
因为这是我的问题,所以通过双击Windows 10执行旧游戏(大约在2003年使用D3D8)是可以的。通过使用的第二个可执行文件(大约在2003年)执行游戏CreateProcess有时看起来还可以。
但是通过我的新golang可执行文件执行该命令将无法正常工作。我得到一个非常小的屏幕。所以我想了解技术上的区别。
供参考,我的golang代码如下:(小屏幕)
cmd := exec.Command(filepath.Join(".", "Game.exe"))
err := cmd.Start()
Run Code Online (Sandbox Code Playgroud)
拆解辅助可执行文件会给我以下信息:(正常屏幕)
CPU Disasm
Address Hex dump Command Comments
004043AF |. 51 PUSH ECX ; /pProcessInformation = 59C7F521 -> {hProcess=???,hThread=???,ProcessID=???,ThreadID=???}
004043B0 |. 52 PUSH EDX ; |pStartupInfo => OFFSET LOCAL.16
004043B1 |. 68 28E54000 PUSH OFFSET 0040E528 ; |CurrentDirectory = "."
004043B6 |. 50 PUSH EAX ; |pEnvironment => NULL
004043B7 |. 50 PUSH EAX ; |CreationFlags => 0
004043B8 |. …Run Code Online (Sandbox Code Playgroud) 我正在按照谷歌上找到的公式开始使用CreateProcess的流程.我想知道的是,我可以设置创建过程的进程名称,以便在任务管理器中显而易见吗?
谢谢你, -
道格拉斯
我想知道sysinternals的psexec.exe如何作为SYSTEM用户执行进程.我需要在SYSTEM进程下运行一个工具,但如果不将其注册为服务,我真的不知道该怎么做.
有没有人有想法?
ps我真的更喜欢使用WINAPI(C++).谢谢!:-)
谢谢!
我有一个NT调用Delphi 7编写的控制台程序的服务,让我们调用它failover.exe,然后NETSH使用我发现的程序调用:
procedure ExecConsoleApp(CommandLine: ansistring; Output, Errors: TStringList);
Run Code Online (Sandbox Code Playgroud)
注意:ExecConsoleApp使用CreateProcess,请参阅以下链接获取完整代码:http://www.delphisources.ru/pages/faq/base/createprocess_console.html
我会在调用之前将以下内容传递给CommandLine ExecConsoleApp:
cmd.exe /c "C:\Windows\system32\netsh.exe interface delete address "Wireless Network Connection" 192.168.0.36"
Run Code Online (Sandbox Code Playgroud)
ExecConsoleApp 将返回错误:
该系统找不到指定的文件
但是,如果我在命令提示符下运行它,它运行完美.
奇怪的是,我记得它在2003 Server上的第一次尝试工作,但在那之后,无论我尝试多少次都失败了.在其中一次尝试中,我还尝试将登录作为管理员用户分配给服务但无济于事.也没有摆弄文件安全帮助.
我没有Win 2003服务器在办公室进行测试,但我已经在XP和Win7上测试过它并且ExecConsoleApp工作得很好,虽然在XP上,我不得不修改ExecConsoleApp执行system32\wbem以便它工作:
Res := CreateProcess(nil, PChar(CommandLine), nil, nil, True,
// **** Attention: Amended by to point current directory to system32\wbem, this is to solve an error returned by netsh.exe if not done otherwise.
// CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, …Run Code Online (Sandbox Code Playgroud) 我需要创建一个新进程,但它是另一个进程的“子进程”,而不是当前进程,例如重新创建新进程的父进程。
以下使我几乎到了.NET:如何使用 C#和.NET 的STARTUPINFOEX 调用 CreateProcessAsUser() :如何 PInvoke UpdateProcThreadAttribute和http://winprogger.com/launching-a-non-child-process/
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
public class ProcessCreator
{
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool CreateProcess(
string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes,
ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags,
IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref STARTUPINFOEX lpStartupInfo,
out PROCESS_INFORMATION lpProcessInformation);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool UpdateProcThreadAttribute(
out IntPtr lpAttributeList, uint dwFlags, IntPtr Attribute, IntPtr lpValue,
IntPtr …Run Code Online (Sandbox Code Playgroud) 这是“sleeper.exe”的源代码,我有:
int main(int argc, char** argv) {
cout<<argv[1];
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我像这样从命令行调用时:
C:\sleeper 5
Run Code Online (Sandbox Code Playgroud)
我懂了
5
Run Code Online (Sandbox Code Playgroud)
在命令行中,所以这工作正常..
现在我试图从其他一些 exe 中调用这个 exe,如下所示:
std::cout << "ret is:" << ret;
std::cout << "\n";
CreateProcess("sleeper.exe", // No module name (use command line)
ret, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // …Run Code Online (Sandbox Code Playgroud) 我无法让它工作,所以我从CreateProcess()into获得 UTF-8 输出wstring。
目前我正在运行此方法来执行此操作,但没有 UTF-8 输出:
HANDLE g_hChildStd_OUT_Rd = NULL;
HANDLE g_hChildStd_OUT_Wr = NULL;
HANDLE g_hChildStd_ERR_Rd = NULL;
HANDLE g_hChildStd_ERR_Wr = NULL;
PROCESS_INFORMATION CreateChildProcess(void);
void ReadFromPipe(PROCESS_INFORMATION);
string run(char *command){
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
if ( ! CreatePipe(&g_hChildStd_ERR_Rd, &g_hChildStd_ERR_Wr, &sa, 0) ) {
exit(1);
}
if ( ! SetHandleInformation(g_hChildStd_ERR_Rd, HANDLE_FLAG_INHERIT, 0) ){
exit(1);
}
if ( ! CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &sa, 0) ) {
exit(1);
}
if ( ! SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, …Run Code Online (Sandbox Code Playgroud) 所以我一直在尝试制作一个可以与网页交互输入数据的程序。理想情况下,我想使用 Chrome,所以我尝试设置 Selenium WebDriver 和 ChromeDriver。
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class Chrome {
public static void main(String[] args) {
//Set chromedriver path
System.setProperty("webdriver.chrome.driver","C:/Users/Username/Desktop/Comp Sci work/chromedriver.exe");
WebDriver driver = new ChromeDriver();
// Open Google
driver.get("http://www.google.com");
// Maximize browser
driver.manage().window().maximize();
}
}
Run Code Online (Sandbox Code Playgroud)
我似乎已经正确设置了外部 JAR,因为我可以毫无问题地导入它们。问题是由于某种原因无法创建 Chrome 进程。我认为这可能是因为已经打开了一个 Chrome 进程,但没有。当我终止进程时,我仍然遇到同样的错误。
然后我尝试设置重置 Chrome 的路径,因为默认路径可能与我的不同,但仍然没有运气。
public class Chrome {
public static void main(String[] args) {
//Set chromedriver path
System.setProperty("webdriver.chrome.driver","C:/Users/Username/Desktop/Comp Sci work/chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Users\\Username\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
WebDriver driver = new ChromeDriver();
// …Run Code Online (Sandbox Code Playgroud)