0

我想通过 C 程序中的 execl 函数调用来执行 winexe 命令。如果我在 execl 调用中硬编码凭据和机器名称,它可以工作,如下所示

execl("winexe","winexe","-U","Domain/Username%Password","//hostname","ipconfig",NULL)

但是,如果我用变量替换主机名或凭据,它就不起作用。

execl("winexe","winexe","-U",credentials_variable,hostname_variable,"ipconfig",NULL)

输出:

winexe version 1.00
This program may be freely redistributed under the terms of the GNU GPLv3
Usage: winexe [-?] [-?] [-?] [-?NP] [-?NPV] [-?|--help] [--usage] [-d|--debuglevel DEBUGLEVEL]
        [--debug-stderr] [-s|--configfile CONFIGFILE] [--option=name=value]
        [-l|--log-basename LOGFILEBASE] [--leak-report] [--leak-report-full]
        [-R|--name-resolve NAME-RESOLVE-ORDER]
        [-O|--socket-options SOCKETOPTIONS] [-n|--netbiosname NETBIOSNAME]
        [-S|--signing on|off|required] [-W|--workgroup WORKGROUP]
        [--realm=REALM] [-i|--scope SCOPE] [-m|--maxprotocol MAXPROTOCOL]
        [-U|--user [DOMAIN/]USERNAME[%PASSWORD]] [-N|--no-pass]
        [--password=STRING] [-A|--authentication-file FILE] [-P|--machine-pass]
        [--simple-bind-dn=STRING] [-k|--kerberos STRING] [-V|--version]
        [--uninstall] [--reinstall] [--system]
        [--runas=[DOMAIN\]USERNAME%PASSWORD] [--runas-file=FILE]
        [--interactive=0|1] [--ostype=0|1|2] //host command

上面的输出表明这是一个语法错误。但我在变量中使用了确切的字符串,包括 / 和 %。请注意,我正在从文件中读取上述变量。我已经使用 execl 函数将变量作为参数传递给其他命令,但我不知道为什么 winexe 不起作用!

请让我知道如何在 execl 函数调用中使用变量作为 winexe 参数。

4

0 回答 0