Gerry Peters Posted April 18, 2016 Report Share Posted April 18, 2016 I've figured out how to get a How to get a Command prompt (admin) window open, but can't figure out how to get it to add text in the Command prompt window? I need it to type diskpart (ENTER) then select volume 5assign letter=Slist volumeselect volume 1assign letter=T Once it's open, I can type on my keyboard and text shows up. Any suggestions? Quote Link to comment Share on other sites More sharing options...
Samrae Posted April 18, 2016 Report Share Posted April 18, 2016 Doesn't the Text Type command work in the Command Prompt? What version of Windows are you using? Quote Link to comment Share on other sites More sharing options...
Gerry Peters Posted April 18, 2016 Author Report Share Posted April 18, 2016 Using Win 10 I have launch and activate cmd.exe - Shortcut.lnk 1 sec delay Text Type: DISKPART (ENTER) Text Type: my script the CMD window opens, but no text is inputted Maybe it has something to do with making that the active window. I'm not sure how to do that Quote Link to comment Share on other sites More sharing options...
rberq Posted April 18, 2016 Report Share Posted April 18, 2016 Put the commands into a batch file, for example c:\temp\cmdlist.bat Then your macro can run cmd.exe with the parameter "/c c:\temp\cmdlist.bat", which runs the DOS batch file. Click to expand the image below. If you need to dynamically build the batch file with commands that vary from one time to another (rather than code it once ahead of time), you can do that with the ME file commands, or by opening Notepad and using ME text-type commands to build the batch file that way. (Because Notepad is a Windows application, the text-type commands work perfectly well there.) Then save the Notepad file by having ME type the file-save commands, and run the batch file as indicated above. Quote Link to comment Share on other sites More sharing options...
Gerry Peters Posted April 19, 2016 Author Report Share Posted April 19, 2016 I still can't get any text to show up in the admin command prompt window. I suppose I'm doing something wrong. Here's what I'm doing. I looked closely at the picture you put in your post. This is a very simple macro with only 1 macro script showing up in the scripting editor: Activate/Launch Program Program launch only - is checked program parameters: /e e:\My Documents\DISKPART ASSIGN S+T TO VOL 5+1.BAT I also tried /c e:\My Documents\DISKPART ASSIGN S+T TO VOL 5+1.BAT Since I wasn’t sure if /c was a command or it c referred to drive C I created a BAT file named DISKPART ASSIGN S+T TO VOL 5+1.BAT I used notepad and here's the text in the BAT file diskpartselect volume 5assign letter=Slist volumeselect volume 1assign letter=T I’m not experienced with BAT file syntax. I assume that the ENTER key will be hit after the word diskpart. because it needs to wen typing manually. But at this point no text at all appears in the CMD window. I also tried the regular CMD instead of the CMD (admin) and same thing – no text Let me know if you see any mistakes in what I’ve done Quote Link to comment Share on other sites More sharing options...
acantor Posted April 19, 2016 Report Share Posted April 19, 2016 You may not need to run the program from the Run prompt. In Windows 7, the full path is C:\Windows\System32\diskpart.exe Assuming the full path to diskpart.exe is the same in Windows 10, use Macro Express's "Program Launch," specifying the full path. Quote Link to comment Share on other sites More sharing options...
Gerry Peters Posted April 19, 2016 Author Report Share Posted April 19, 2016 If I use Run (Win-R) I can type C:\Windows\System32\diskpart.exe hit enter ad nit does open a CMD (ADMIN) window with dispart, so that's good. But if I put C:\Windows\System32\diskpart.exe in the Program/Path/name window of the Activate/Launch window and run the macro it immediately opens and closes the DOS window. Same problem, I'm getting no text inputted into the CMD window Are the program parameters I'm using correct in my example, two posts above this? I had to modify them to adapt to my situation. Are you able to get any text from macro express show up in the CMD window? If so maybe you can upload the macro to MS Onedrive, so I can see what's different thanks, Quote Link to comment Share on other sites More sharing options...
rberq Posted April 19, 2016 Report Share Posted April 19, 2016 The batch file you built looks fine -- just the commands you would type in a DOS window if you were doing it manually. For debugging, I always like to use PAUSE as the very last line of the batch file, so the command window won't close before you have a chance to look at it. Once you are happy with how everything is working you can remove the PAUSE. However, the system does not like embedded blanks within the batch file name. In the program launch parameters, try it like this with double-quotes around the path-name: /c "e:\My Documents\DISKPART ASSIGN S+T TO VOL 5+1.BAT" And it is /c or /k you need at the beginning of the line, not /e. When I run my test macro with /e, it opens the command window but does nothing further, just like when you did it. P.S. I am using the terms "DOS window" and "CMD window" and "command window" interchangeably. Sorry, I don't know which is currently the accepted term, but I pre-date DOS so that's what I am used to. Quote Link to comment Share on other sites More sharing options...
Samrae Posted April 19, 2016 Report Share Posted April 19, 2016 You mentioned "CMD (ADMIN) window". If your cmd prompt is running as administrator then you must run Macro Express as administrator. Windows will not allow a program running with non-admin privileges to type into a program running with admin privileges. Quote Link to comment Share on other sites More sharing options...
Gerry Peters Posted April 19, 2016 Author Report Share Posted April 19, 2016 I terminated ME. Then at start button typed macro. I saw Macro Express at the top of the window. I right clicked on it and chose run as administrator. Put the pause at the end of my BAT file script you see below. Changed the program launch parameters,to /c "e:\My Documents\DISKPART ASSIGN S+T TO VOL 5+1.BAT" I ran the macro. The DOS window closed right away and the drive letters didn't change. I decided to try and simplify this some, so here’s the new name and folder of my BAT file C:\1\DISKPAR2.BAT Here’s the script of the BAT file diskpartselect volume 5assign letter=Slist volumeselect volume 1assign letter=TPAUSE program parameters: /c C:\1\DISKPAR2.BATProgram path: C:\Windows\System32\diskpart.exe I ran the new Macro – same results, window closes right away and no changes to drive letters. I’m beginning to wonder if anyone has ever used ME with a CMD (admin) and got any text inputted. Can anyone verify that they’ve done this? If so can you upload the macro for us to see? Quote Link to comment Share on other sites More sharing options...
rberq Posted April 20, 2016 Report Share Posted April 20, 2016 I have done it many times – but not in Administrator mode. You are trying to have Macro Express run cmd.exe so the program path should be c:\windows\system32\cmd.exe When cmd.exe runs, the parameter it will act upon is (with your new name) /c C:\1\DISKPAR2.BAT In other words, all that your macro does is – indirectly – launch a batch file. It is the batch file, NOT the macro, that runs DISKPART. (The first line of your batch file is DISKPART.) The batch file, once started, runs totally independently of Macro Express. Unfortunately the batch file that runs DISKPART must run in admin mode. Sorry, I missed that point about DISKPART in my earlier replies. Here’s a link to how to do that, by creating a shortcut to run the batch file. http://superuser.com/questions/788924/is-it-possible-to-automatically-run-a-batch-file-as-administrator So you have to go another layer down and have your macro launch the shortcut rather than the batch file itself. Don’t you love Windows? When I tried this it DID work, but popped up the Windows box requesting that I authorize changes to my computer. I haven’t been able to get it to run without that manual intervention – maybe if you run ME itself in admin mode as someone suggested above??? At any rate, put PAUSE statements at the beginning and end of your batch file, so it will stop for you to look at it when (if) it runs. Quote Link to comment Share on other sites More sharing options...
Gerry Peters Posted April 20, 2016 Author Report Share Posted April 20, 2016 we're getting somewhere now. I put this in Program path box: E:\Desktop\cmd.exe - Shortcut.lnk I have run as adminstrator checked like the link suggested. I modified my BAT file to this PAUSEdiskpartselect volume 5assign letter=Slist volumeselect volume 1assign letter=TPAUSE The DOS window opened and said hit any key to continue and it did indeed type diskpart and go to that directory, but that's where it stops. I tired putting some extra pauses there like after diskpart - nothing seems to help Thanks we're getting close Quote Link to comment Share on other sites More sharing options...
rberq Posted April 20, 2016 Report Share Posted April 20, 2016 Getting somewhere, yes. But maybe you need still another layer upon layers? Worse than Alice in Wonderland. Here’s a brief excerpt from the web (link to the site is after the excerpt). The way I interpret this is, your existing batch file should have the DISKPART command with the /s option, and the subsequent commands should be in a separate text file.To start a DiskPart script, at the command prompt, type:diskpart /s scriptname .txtwhere scriptname is the name of the text file that contains your script.To redirect DiskPart's scripting output to a file, type:diskpart /s scriptname .txt > logfile .txtwhere logfile is the name of the text file where DiskPart writes its output.https://technet.microsoft.com/en-us/library/cc766465%28v=ws.10%29.aspxSo your batch file would be simply something like this:PAUSEdiskpart /s c:\dpscript.txtPAUSEAND you must make file c:\dpscript.txt containing the commands:select volume 5assign letter=Slist volumeselect volume 1assign letter=TI don’t know whether you will see the output from DISKPART on the screen, as it runs, or not. You might need to pipe the output to a log file as indicated in the example, then look at the log afterwards to see what happened. diskpart /s c:\dpscript.txt > c:\dplog.txt Quote Link to comment Share on other sites More sharing options...
Gerry Peters Posted April 20, 2016 Author Report Share Posted April 20, 2016 I didn't have permission to put the txt file in C:\ so I put it in system 32 folder like the original tutorial suggested, but I got this error DiskPart was unable to open or read the script file. Make sure the file you specified exists. So I guess it's maybe another administrator problem, so then I put the txt file in E:\ and redid my BAT file like this PAUSE diskpart /s E:\\dpscript.txt PAUSE AND IT WORKED!!!!!! Thank you we finally did it . Quote Link to comment Share on other sites More sharing options...
rberq Posted April 20, 2016 Report Share Posted April 20, 2016 Nothing is easy. Until it's done, then it's obvious. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.