如何传递目录路径作为进程的命令行? [英] How to pass the Directory path as command line for the process?

查看:77
本文介绍了如何传递目录路径作为进程的命令行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iam使用regasm.exe来生成tlb文件并注册程序集。但是tlb在.NET根目录本身的路径。所以像这样



缓冲区包含c:\windows \Microsoft.Net\framework\v2.0.57\RegAsm.exe

  if(!CreateProcessW(buffer,LC:\\Program Files\\Test\\Test.dll / codebase / tlb / silent,NULL,NULL,FALSE,0,NULL,NULL,(LPSTARTUPINFOW)& pi,& pi))

但我认为它不会采取完整的路径,因为有一个空白b / w Program和Files.as期望当我运行命令,它也显示无法找到输入程序集c:\program。



通常在命令提示符下,我们可以给出



RegAsm.exe c:\program file \Test\test.dll/ codebase / tlb
这个粗体字符我必须作为命令行传递,但它有双引号的双quptes。

解决方案



您需要在字符串中用引号将路径括起来,您可以通过使用反斜杠转义引号字符来执行此操作。因此,CreateProcessW的第二个参数是:

  L\C:\Program Files\Test\ Test.dll\/ codebase / tlb / silent

您将在命令提示符处使用的引号。


iam using regasm.exe to generate tlb file and register the assembly programatically.But the path of tlb in .NET root directory itself. so do like this

buffer contains c:\windows\Microsoft.Net\framework\v2.0.57\RegAsm.exe

if(!CreateProcessW(buffer,L" C:\\Program Files\\Test\\Test.dll  /codebase /tlb /silent" ,NULL, NULL,FALSE, 0,NULL,NULL,(LPSTARTUPINFOW)&si,&pi ) )

But i think it wont take full path since there is a blank b/w Program and Files.as expected the when i run the command it also shows unable to locate input assembly c:\program.

normally at command prompt we can give as

RegAsm.exe "c:\program files\Test\test.dll" /codebase /tlb this bold characters i have to pass as command line but it have Double quptes with in double quotes. so i was strucked.

How can i fix it

解决方案

You need to enclose the path in quotes within the string, which you can do by escaping the quote character by preceding it with a backslash. So, your 2nd parameter to CreateProcessW would be:

L"\"C:\Program Files\Test\Test.dll\" /codebase /tlb /silent"

This would give you the command line with quotes that you would use at the command prompt.

这篇关于如何传递目录路径作为进程的命令行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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