Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在windows中不使用cmd.exe创建文件夹_Windows_Cmd_Rundll32 - Fatal编程技术网

在windows中不使用cmd.exe创建文件夹

在windows中不使用cmd.exe创建文件夹,windows,cmd,rundll32,Windows,Cmd,Rundll32,编辑:我有一个专有的应用程序,它只支持使用参数执行windows命令和可执行文件(仅从windows文件夹),我需要使用它创建文件夹,但我不想看到cmd窗口闪烁。此应用程序不支持任何dll导入或代码自定义 有没有办法在没有命令提示的情况下在windows中创建文件夹?当我跑的时候 cmd /C mkdir "C:\Path\To\Dir" rundll.exe shell32.dll,SHCreateDirectory "C:\Path\To\Dir" 它会导致快速显示和隐藏cmd窗口的

编辑:我有一个专有的应用程序,它只支持使用参数执行windows命令和可执行文件(仅从windows文件夹),我需要使用它创建文件夹,但我不想看到cmd窗口闪烁。此应用程序不支持任何dll导入或代码自定义

有没有办法在没有命令提示的情况下在windows中创建文件夹?当我跑的时候

cmd /C mkdir "C:\Path\To\Dir" 
rundll.exe shell32.dll,SHCreateDirectory "C:\Path\To\Dir" 
它会导致快速显示和隐藏cmd窗口的闪烁(我想避免这种情况)。 当我跑的时候

cmd /C mkdir "C:\Path\To\Dir" 
rundll.exe shell32.dll,SHCreateDirectory "C:\Path\To\Dir" 

命令通过得很好,但没有创建我想要创建的目录。如果有这样的命令也可以创建具有完全不存在路径的direcotry,那就太好了

编辑2: 我发现有点棘手,但正在解决此问题: 我发现我可以使用那个专有应用程序创建文本文件。首先,我创建了一个文件: run.vbs 然后我写了几行:

If WScript.Arguments.Count >= 1 Then
    ReDim arr(WScript.Arguments.Count-1)
    For i = 0 To WScript.Arguments.Count-1
        Arg = WScript.Arguments(i)
        If InStr(Arg, " ") > 0 Then Arg = """" & Arg & """"
      arr(i) = Arg
    Next
    RunCmd = Join(arr)
    CreateObject("Wscript.Shell").Run RunCmd, 0, True
End If
然后跑

wscript run.vbs cmd /C mkdir "C:\Temp\TmP"

还有沃拉

如果您无法控制流程的创建方式,那么您基本上处于该代码实现者的默西状态。winapi确实运行*.bat和/或*.cmd文件,但通过%ComSpec%/c运行,通常是cmd.exe/c。但是,.bat文件在这里是不好的,因为cmd运行它们,这会打开一个控制台

以下是一些在您的情况下可能有效或可能无效的选项:

选项1(来自@HarryJohnston的想法) 使用以下powershell命令

powershell -WindowStyle Minimized -NoLogo -NoProfile -NonInteractive -Command mkdir c:\your\path\tocreate > %temp%\scratch.txt
选择2 让脚本解释器运行以下文件:

o的尺寸
Set of so=CreateObject(“Scripting.FileSystemObject”)
'创建新文件夹
oFSO.CreateFolder WScript.Arguments.Item(0)
您可以使用以下命令开始:

wscript mkdirsil.vbs "c:\path\to\create" //NoLogo
//Nologo阻止徽标显示:执行时不会显示任何横幅

选择3 编译以下C#Winforms程序,使其主窗口保持隐藏状态。您需要部署可执行文件,我不知道这是否可行

使用系统;
使用System.Windows.Forms;
使用System.IO;
名称空间SilentMkDir
{
公共课程:表格
{
公共程序(字符串目录)
{
这个.SuspendLayout();
this.ClientSize=新系统.Drawing.Size(0,0);
this.ControlBox=false;
this.ebox=false;
this.ebox=false;
this.ShowIcon=false;
this.ShowInTaskbar=false;
this.StartPosition=System.Windows.Forms.FormStartPosition.Manual;
this.Text=“MakeDir”;
this.WindowState=System.Windows.Forms.FormWindowState.Minimized;
这个.Load+=(s,e)=>
{
尝试
{
CreateDirectory(dir);
}
捕获(所有例外)
{
MessageBox.Show(all.Message);
}
这个。关闭();
};
此选项为.resume布局(false);
}
/// 
///应用程序的主要入口点。
/// 
[状态线程]
静态void Main(字符串[]路径)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
运行(新程序(路径[0]);
}
}
}
此命令行应该为您生成一个*.exe,上面的代码位于
mksil.cs

csc mksil.cs /r:System.IO.dll /r:System.Windows.dll
或者您可以在C/C++中创建类似的东西

备选方案4(idea@eryksun) 安装Python后,您可以

因为pyw.exe是一个GUI应用程序

您基本上是在寻找一个exe,它是一个Windows GUi应用程序,而不是一个控制台应用程序。下面的批处理命令扫描系统文件夹以查找此类可执行文件(将其放在一行上),但未找到任何可执行文件。(请注意,这需要从命令行运行,从脚本文件使用%%a而不是%a。VC++编译器附带

(%SystemRoot%\System32\*.exe)中%a的
执行
@(垃圾箱/头%a |
查找“子系统(Windows GUI)”>nul&&
回声(nxa)
选项不可能 起初我希望
start
可以工作,但@HarryJohnston指出它是cmd的内部命令,而不是exe

start /B /min cmd /c mkdir
启动单独的窗口以运行指定的程序或命令


但使用/B(无新窗口)和/MIN(最小化)你可能会侥幸逃脱。

如果你无法控制进程的创建方式,那么你基本上处于代码实现者的默西状态。winapi确实运行*.bat和/或*.cmd文件,但通过%ComSpec%/c运行,通常是cmd.exe/c。但是,.bat文件在这里不好,因为cmd运行它们,这会打开一个控制台

以下是一些在您的情况下可能有效或可能无效的选项:

选项1(来自@HarryJohnston的想法) 使用以下powershell命令

powershell -WindowStyle Minimized -NoLogo -NoProfile -NonInteractive -Command mkdir c:\your\path\tocreate > %temp%\scratch.txt
选择2 让脚本解释器运行以下文件:

o的尺寸
Set of so=CreateObject(“Scripting.FileSystemObject”)
'创建新文件夹
oFSO.CreateFolder WScript.Arguments.Item(0)
您可以使用以下命令开始:

wscript mkdirsil.vbs "c:\path\to\create" //NoLogo
//Nologo阻止徽标显示:执行时不会显示任何横幅

选择3 编译下面的C#Winforms程序以隐藏其主窗口。您需要部署可执行文件,我不知道这是否可行

使用系统;
使用System.Windows.Forms;
使用System.IO;
名称空间SilentMkDir
{
公共课程:表格
{
公共程序(字符串目录)
{
这个.SuspendLayout();
this.ClientSize=新系统.Drawing.Size(0,0);
this.ControlBox=false;
this.ebox=false;
this.ebox=false;
this.ShowIcon=false;
this.ShowInTaskbar=false;
this.StartPosition=System.Windows.Forms.FormStartPosition.Manual;
this.Text=“MakeDir”;
this.WindowState=System.Windows.Forms.FormWindowSta