If you can't control how your process is created you are basically at the mersey of the implementers of that code. The winapi CreateProcess does run *.bat and/or *.cmd files but via %ComSpec% /c, which is normally cmd.exe /c. But then, .bat files are no .good here exactly because cmd runs them, which opens a console
Here are a few options that might or might not work in your case:
Option 1 (idea from @HarryJohnston)
Use the following powershell command
powershell -WindowStyle Minimized -NoLogo -NoProfile -NonInteractive -Command mkdir c:\your\path\tocreate > %temp%\scratch.txt
Option 2
Have the script interpreter run the following file:
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Create a new folder
oFSO.CreateFolder WScript.Arguments.Item(0)
which you start with the following command:
wscript mkdirsil.vbs "c:\path\to\create" //NoLogo
//Nologo Prevent logo display: No banner will be shown at execution time
Option 3
Compile the following C# Winforms program that keeps its main window hidden. You need to deploy the executable and I don't know if that is feasible.
using System;
using System.Windows.Forms;
using System.IO;
namespace SilentMkDir
{
public class Program:Form
{
public Program(string dir)
{
this.SuspendLayout();
this.ClientSize = new System.Drawing.Size(0, 0);
this.ControlBox = false;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "MakeDir";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Load += (s, e) =>
{
try
{
Directory.CreateDirectory(dir);
}
catch (Exception all)
{
MessageBox.Show(all.Message);
}
this.Close();
};
this.ResumeLayout(false);
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] path)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Program(path[0]));
}
}
}
This commandline should produce an*.exe for you, asuming above code is in mksil.cs
csc mksil.cs /r:System.IO.dll /r:System.Windows.dll
Or you could create something similar in C/C++.
Option 4 (idea @eryksun)
With Python installed you could do
pyw -c "import os; os.mkdir(r'C:\Path\To\Dir')"
since pyw.exe is a GUI app
You are basically looking for an exe that is a Windows GUi application instead of a Console application. The following batch command scans the system folder for such executables (put it on one line) but none were found. (notice this needs to run from the commandline, from a script file use %%a instead of %a. dumpbin
comes with the VC++ compiler
for %a in (%SystemRoot%\System32\*.exe) do
@(dumpbin /headers %a |
find "subsystem (Windows GUI)" > nul &&
echo %~nxa)
Option Not Possible
Initially I hoped start
could work but @HarryJohnston pointed out that it is an internal command of cmd and not an exe.
start /B /min cmd /c mkdir
Starts a separate window to run a specified program or command.
but with the /B (no new window) and /MIN (minimized) you might get away with it.