Tuesday 15 July 2014

file - Open the "open"-dialogbox from cmd -


I want to know that I can open "Open" - Dialog box from CMD, so I can use it to open Right file for (I already know how to open files directly from CMD, but not those who are interested in it)

Currently I am doing a project where I have a program (like program .XA). This program needs a model (eg modelfile.mod) I execute in CMD by writing the program: program.exe modelfile.mod, and it works. I have several models with different names, but the program file always has the same name. Every time I need to perform the program in CMD, I would like to make a batch, where I can select the modf which I would like to execute, after which it will run the program with the modf selected as the input .

So I need to know how to open the "open" dialog box from CMD, and how to get the name of the file selected for use in the execution of the program.

  @echo off setlocal set ps_cmd = powershell "class = "Post-lesson" itemprop = "text"> 

Add-Type -AssemblyName System.windows.forms | Out-Null; $ f = New Object System.window.form.openfileDialoghood; $ f.Filter = 'Model Files (* .mod) | * .mod | All Files (*. *) * *. * '; $ F.showHelp = $ true; $ f.ShowDialog () | Out-null; $ f.FileName "for / F "delims =" In %% I ('% ps_cmd%') set the defined filename = "%% I" if you defined the filename (the echo you chose% filename%) Other ( You choose not Skvet!) Goto: EOF

or if you want to break the powers Elseedilets for easy maintenance:

  @echo off setlocal set "Ps = add-type -AssemblyName System.windows.forms | out-null;" set "ps =% ps% $ f = new object system. Windows.form.openfile dialog;" set "ps =% ps% $ f .Filter = 'Model Files (* .mod) | *. Mod | All Files (*. *) | *. *'; "Set" ps =% ps% $ f.showHelp = $ true; "Set" ps =% ps% $ f.ShowDialog () | Out-null; "Set" ps =% ps% $ f.FileName "for / f" delims = "%% I ( 'powershell'% ps% '') in" filename = %% I "set that defines the file name (echo you % have chosen filename%) other (echo you chose not Skvet!) goto: EOF   

set see the documentation for cruelly taken.) other properties written (PowerShell commands, like Title and Initial Directory .

No comments:

Post a Comment