Ferret Posted July 28, 2006 Share Posted July 28, 2006 I am having troubles using either the Run or RunWait commands. Trying to call a windows .cmd file. Here's some of the things I've tried (partial code): RunAsSet ($d_usrnm, @LogonDomain ,$d_usrnmpwd, 0) $Exe = '"' & @COMSPEC & ' /c ' & $cmdtorun & '"' $PID = Run ($Exe,"C:\",@SW_HIDE) ProcessWaitClose($PID) In the above code, the interpretter seems to not believe me that I want the window hidden. It displays a standard window while it executes. I've tried supplying the numeric value as well as the Maximize and Minimize values, but it always performs the same way. Now, another problem I have is that I really don't want to run in the C:\ as my working directory. I have tried using just "" and @ScriptDir. Either way I get this error: Unable to execute the external program. The system cannot find the path specified. Now I guess I should mention that it's a UNC path on the network. Is that causing the problem? Any assistance is really appreciated! Murphy lives here.My website, if you care: HIPAA Information Security Resources Link to comment Share on other sites More sharing options...
jefhal Posted July 28, 2006 Share Posted July 28, 2006 I am having troubles using either the Run or RunWait commands. Trying to call a windows .cmd file.Most of the exe's that I run are on network drives, not on my local machine. It is difficult to guess what is happening, as you did not (could not) tell us what you are actually executing, however, what happens when you run the file from the Start-Run box in windows? Does it open a command window? ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Excalibur Posted July 28, 2006 Share Posted July 28, 2006 I'm a bit unsure of what your trying to accomplish, but to save you ALOT of trouble, you can execute commands in dos simply using the User Defined Function (UDF) _RunDOS( $sCommand ) located in the process.au3 library. Simply include #Include <process.au3> at the top of your script and run each of the lines you wanted in the cmd file with the _RunDOS function, and no window will appear. Saves you the trouble of hideing a window and more flexability. :-) Hope this helped. :-) Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein Link to comment Share on other sites More sharing options...
jefhal Posted July 28, 2006 Share Posted July 28, 2006 Any assistance is really appreciated!Does this work?RunAsSet ($d_usrnm, @LogonDomain ,$d_usrnmpwd, 0) $PID = Run(@COMSPEC & ' /c ' & '\\myserver\sharename\myexe.exe',@TempDir,@SW_HIDE) ProcessWaitClose($PID) ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
jefhal Posted July 28, 2006 Share Posted July 28, 2006 you can execute commands in dos simply using the User Defined Function (UDF) _RunDOS( $sCommand ) located in the process.au3 library.I did not know that! I learn something new every day! Thanks, Excalibur (and the AutoIT design team)... ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Excalibur Posted July 28, 2006 Share Posted July 28, 2006 :-D. DOS, cant leave home without it. ;-) :-P Ooo Ëxçã¿îbúr ooO"Information Is Not Knowledge." ~Albert Einstein Link to comment Share on other sites More sharing options...
Ferret Posted July 28, 2006 Author Share Posted July 28, 2006 (edited) Most of the exe's that I run are on network drives, not on my local machine. It is difficult to guess what is happening, as you did not (could not) tell us what you are actually executing, however, what happens when you run the file from the Start-Run box in windows? Does it open a command window?Well I tried that one and I had the same error.A little more explanation: I am writing something that will read an encrypted file containing credentials and commands to run as those credentials. So it performs a RunAsSet with the encrypted credentials and then it is supposed to perform the encrypted command. In this case, the encrypted command is a full path to a .cmd file. I have debugged it during execution (Msgbox appears with the string) to insure that the path is correct when decrypted.Here's the command its trying to run: "nmh-new-fap01-1\NMH\Software\Mst\Patches\API\InstallAPI"Thanks for the help. So I tried the other suggestion, using @TempDir, and that works. So it looks like the '_RunDos' is out for this script. But now, the file is not running. When I remarkout the RunAsSet command, it works with my credentials. Hmmm. Seems like I have a new problem.Thanks for all of your help. Edited July 28, 2006 by Ferret Murphy lives here.My website, if you care: HIPAA Information Security Resources Link to comment Share on other sites More sharing options...
MHz Posted July 28, 2006 Share Posted July 28, 2006 To run a .cmd file is Run('Path\To\file.cmd')oÝ÷ Úz0~Ѻp,IëHÂ)e¡÷Þ¯gåjú.®Í_¢ºZ²Ì(×r)ì׬r¸©¶ÚuÛâiÊ&©Ý)Þ)e½ªâi¹^±ú+ÖËlr¸©µ«¢+Ø(ìÕѽIÕ¸ÅÕ½ÐíMÉ¥ÁйáÅÕ½Ðì̵¥¸)Õ¹=¹Õѽ%ÑMÑÉÐ ¤($ìUÍȹµ(%1½°ÀÌØíÕÍÈôÌäìÌäì($ì½µ¥¸¹µ(%1½°ÀÌØí½µ¥¸ôÌäìÌäì($ìAÍÍݽÉ(%1½°ÀÌØíÁÍÍݽÉôÌäìÌäì($ì($ì ¡¬¥¹½µ¥¹ÁɵÑÉÌ(%%9½ÐÀÌØí 51%9lÁtQ¡¸($$ì9¼ÁɵÑÉÌÑ¡¸ÉÍÑÉÐ̵¥¸($%IÕ¹ÍMÐ ÀÌØíÕÍÈ°ÀÌØí½µ¥¸°ÀÌØíÁÍÍݽɤ($%IÕ¸ ÌäìÅÕ½ÐìÌäìµÀìMÉ¥ÁÑÕ±±AÑ µÀìÌäìÅÕ½Ðì½µ¥¸Ìäì¤($%IÕ¹ÍMÐ ¤($%á¥Ð(%±Í%ÀÌØí 51%9lÅt±ÐìÐìÌäì½µ¥¸ÌäìQ¡¸($$ìá¥ÐÍÉ¥ÁÐÝ¥Ñ á¥Ð½Ä($%á¥ÐÄ(%¹%)¹Õ¹(((ìIÕ¸ÅÕ½ÐíMÉ¥ÁйáUÍȽµ¥¸AÍÍݽÉÅÕ½Ðìä½µµ¹±¥¹)Õ¹=¹Õѽ%ÑMÑÉÐ ¤($ì ¡¬¥¹½µ¥¹ÁɵÑÉÌ(%%9½ÐÀÌØí 51%9lÁtQ¡¸($$ì9¼ÁɵÑÉÌÝ¥±°á¥Ð½È($%á¥ÐÈ(%±Í%ÀÌØí 51%9lÅtôÌäì¼üÌäìQ¡¸($$ìM¡½Ü¡±ÀÑ¡¸á¥Ð($%5Í ½à ÁàÐÀÀÐÀ°Ìäí!±ÀÌäì°ÌäíUÍèÌäìµÀìMÉ¥ÁÑ9µµÀìÌäìUÍȽµ¥¸AÍÍݽÉÌäì¤($%á¥Ð(%±Í%ÀÌØí 51%9lÁtôÌQ¡¸($$ìÌÁɵÑÉÌÑ¡¸ÉÍÑÉÐ̵¥¸($%IÕ¹ÍMÐ ÀÌØí 51%9lÅt°ÀÌØí 51%9lÉt°ÀÌØí 51%9lÍt¤($%IÕ¸ ÌäìÅÕ½ÐìÌäìµÀìMÉ¥ÁÑÕ±±AÑ µÀìÌäìÅÕ½Ðì½µ¥¸Ìäì¤($%IÕ¹ÍMÐ ¤($%á¥Ð(%±Í%ÀÌØí 51%9lÅt±ÐìÐìÌäì½µ¥¸ÌäìQ¡¸($$ìá¥ÐÍÉ¥ÁÐÝ¥Ñ á¥Ð½Ä($%á¥ÐÄ(%¹%)¹Õ¹ Pick a function and add your admin code anywhere outside the function. The function will automatically run when the script starts as AutoIt will search for OnAutoItStart(). Seeing a command console is a apparently a known issue with RunAsSet. Link to comment Share on other sites More sharing options...
Ferret Posted July 28, 2006 Author Share Posted July 28, 2006 Thanks for that code. The goal of my script was to have the ability to create encrypted script files that could have different credentials stored for different things. Then the user wouldn't have to code a new script everytime they wanted to do something. Everything now works. The problem I am having is the AutoIt doesn't seem to 'believe' me when I say @SW_HIDE. It also doesn't let me exclude the "Optional" working directory field. And in fact the only value it seems to accept are 'C:\' or @TempDir. The function just doesn't operate as advertised for me and I cannot figure out why. Murphy lives here.My website, if you care: HIPAA Information Security Resources Link to comment Share on other sites More sharing options...
MHz Posted July 28, 2006 Share Posted July 28, 2006 seems to accept are 'C:\' or @TempDir.Seems like RunAsSet is not working so you need to restart the script as admin as my code above offers. RunAsSet only works with Run() as to the restart trick as being admin.As for seeing a command window, see last line of my last post. Link to comment Share on other sites More sharing options...
Ferret Posted July 28, 2006 Author Share Posted July 28, 2006 (edited) So not being able to hide the console window is an 'undocumented value added feature' of the RunAsSet command? I see. So in short: If you use the RunAsSet command, you must specify a working directory for the Run command, the @SW_HIDE function will not workBTW - It appears the RunWait does work with the RunAsSet command.Thanks, again to all who replied. Edited July 28, 2006 by Ferret Murphy lives here.My website, if you care: HIPAA Information Security Resources Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now