WMIC:如何在特定的工作目录中使用“流程调用创建"? [英] WMIC: how to use **process call create** with a specific working directory?

查看:80
本文介绍了WMIC:如何在特定的工作目录中使用“流程调用创建"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任务是使用wmic process call create "c:\folder\app.exe"启动程序,并让app.exeapp.exe home folder tree中访问其自己的支持文件.

The task is to launch a program using wmic process call create "c:\folder\app.exe" and have app.exe access it's own support files in the app.exe home folder tree.

下面的批处理脚本说明了WMIC静默更改工作目录,从而找不到支持文件的问题.

The batch script below illustrates the problem with WMIC silently changing the working directory, so that the support files cannot be found.

此脚本会创建另一个名为one.bat的批处理文件,该文件只需在同一文件夹中键入url.txt文件,即可在控制台上显示www.google.com.

This script creates a second batch file called one.bat that simply types a url.txt file from the same folder, to display www.google.com on the console.

使用wmic创建进程时,wmic默默更改工作目录,以便找不到one.bat,如果我将完整路径指定为d:\abc\one.bat,则one.bat将启动但找不到要在其自己的文件夹中键入名为url.txt的文件.

When using wmic to create the process, wmic silently changes the working directory so that one.bat is not found and if I specify the full path as d:\abc\one.bat then one.bat will launch but it can't find the file to be typed called url.txt in it's own folder.

如果我将WMIC.EXE文件复制到相同的文件夹,它将以相同的方式失败.

If I copy the WMIC.EXE file to the same folder, it fails in the same way.

@echo off
set "folder=d:\abc"
cd /d "%folder%"

(
echo.@echo off
echo.type url.txt
echo.pause
)>one.bat

(
echo.@echo off
echo.www.google.com
)>url.txt

echo this will work to launch the one.bat but the working directory is wrong and the file can't be found
wmic process call create "%folder%\one.bat"
pause

echo this will not launch one.bat because it can't be found
wmic process call create one.bat
pause

echo this will not launch one.bat as the working directory is changed
copy "%windir%\system32\wbem\wmic.exe" .
.\wmic process call create one.bat
pause

有人知道用于设置此命令工作目录的WMIC开关吗?

Does anyone know of a WMIC switch that will set the working directory for this command?

推荐答案

运行

wmic process call create /?

获取有关为什么这样做的信息

to get the information on why this

wmic process call create "c:\folder\app.exe","c:\folder"

应该工作

这篇关于WMIC:如何在特定的工作目录中使用“流程调用创建"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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