Morteza Posted December 1, 2008 Share Posted December 1, 2008 Anybody know why the following cod will not work? $nResult = RunAsWait("username", @computername,"password",1,"start /wait /b reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /r", @SystemDir, @SW_HIDE) When I delete "Start /wait /b" all things work good, but a command prompt screen is appeared in milisec. I need to disappear this command prompt, so i must use "Start /wait /b" for running "Reg" command. When I execute "start /wait /b reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /r" with Windows RunAs, all thing work good. What is the problem with AutoIt RunAs()? Best Regards Link to comment Share on other sites More sharing options...
Developers Jos Posted December 1, 2008 Developers Share Posted December 1, 2008 Why are you using start in stead of @Comspec? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Morteza Posted December 1, 2008 Author Share Posted December 1, 2008 Why are you using start in stead of @Comspec?Because my need is hiding "REG" command prompt completely and just start can does it. CMD /c have a command prompt windows for itself and I can not hide it too. I used START and CMD in combination with each other, but START can not hide CMD command prompt window and this is just as the same as I use REG without START. Link to comment Share on other sites More sharing options...
jaenster Posted December 1, 2008 Share Posted December 1, 2008 (edited) becourse @comspec and Start isn't the same?With start you can use:start http://www.autoitscript.comWith @comspec you cant use that.But, running start, with @comspec is a better idea i guess.cmd /c "start /wait /b reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /r"edit: Fixed prob of the Bold tag Edited December 1, 2008 by jaenster -jaenster Link to comment Share on other sites More sharing options...
Morteza Posted December 1, 2008 Author Share Posted December 1, 2008 becourse @comspec and Start isn't the same? With start you can use: start http://www.autoitscript.com With @comspec you cant use that. But, running start, with @comspec is a better idea i guess. cmd /c "start /wait /b reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /r" edit: Fixed prob of the Bold tag I was tested your suggestion before my letter. When I use the following code: $nResult = RunAsWait("username", @computername,"password",1,@comspec & " /c start /wait /b reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /r", @SystemDir, @SW_HIDE) Not only REG does not work, but also START is bypassed too and instead of one command prompt window, two command prompt is appeared in milisec. When I changed the above code to the follow: $nResult = RunAsWait("username", @computername,"password",1,"start /wait /b cmd /c reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /r", @SystemDir, @SW_HIDE) Command prompts were reduced to one again, but REG not work as previous. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 1, 2008 Developers Share Posted December 1, 2008 I was referring to something like: $nResult = RunAsWait("username", @ComputerName, "password", 1, @comspec & " /c reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /r", @SystemDir, @SW_HIDE) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Morteza Posted December 1, 2008 Author Share Posted December 1, 2008 I was referring to something like: $nResult = RunAsWait("username", @ComputerName, "password", 1, @comspec & " /c reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /r", @SystemDir, @SW_HIDE) I can understand your scope, but I explained why CMD is not useful for me Link to comment Share on other sites More sharing options...
jaenster Posted December 2, 2008 Share Posted December 2, 2008 With @sw_hide you dont see the cmd -jaenster Link to comment Share on other sites More sharing options...
Morteza Posted December 2, 2008 Author Share Posted December 2, 2008 (edited) With @sw_hide you dont see the cmd If you read my code, you will see this flag is used beforehand, but @SW_HIDE just can hide one window, CMD window or REG window. In anyway, one prompt will be appeared in milisec without START. Test it, you will see that Edited December 2, 2008 by Morteza Link to comment Share on other sites More sharing options...
Developers Jos Posted December 2, 2008 Developers Share Posted December 2, 2008 I can understand your scope, but I explained why CMD is not useful for meI have seen you only use CMD in combination with START and I do not see you explicitely state you tried the command I provide. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Morteza Posted December 2, 2008 Author Share Posted December 2, 2008 (edited) I have seen you only use CMD in combination with START and I do not see you explicitely state you tried the command I provide. Please compile the following code in Console mode and ran the EXE file. I'm sure you will see my problem. func _Test() $nResult = RunAsWait("username", @ComputerName, "password", 1, @comspec & " /c reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /f", @SystemDir, @SW_HIDE) EndFunc For $a = 1 to 5000 _Test() Next Edited December 2, 2008 by Morteza Link to comment Share on other sites More sharing options...
Danny35d Posted December 3, 2008 Share Posted December 3, 2008 I ran your example script _Test() and I didn't see any window. Open task manager and I can see cmd.exe running several times, but no flashing cmd window. I tested in windows xp professional sp2. There is any reason why you cannot run it without @Comspec, tested and work fine for me.$nResult = RunAsWait("username", @ComputerName, "password", 1, "reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /f", @SystemDir, @SW_HIDE) AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
jaenster Posted December 3, 2008 Share Posted December 3, 2008 If you read my code, you will see this flag is used beforehand, but @SW_HIDE just can hide one window, CMD window or REG window. In anyway, one prompt will be appeared in milisec without START. Test it, you will see that -jaenster Link to comment Share on other sites More sharing options...
Morteza Posted December 3, 2008 Author Share Posted December 3, 2008 (edited) I ran your example script _Test() and I didn't see any window. Open task manager and I can see cmd.exe running several times, but no flashing cmd window. I tested in windows xp professional sp2. There is any reason why you cannot run it without @Comspec, tested and work fine for me.$nResult = RunAsWait("username", @ComputerName, "password", 1, "reg add ""HKCU\software"" /v ""Value"" /d ""Data"" /t ""REG_SZ"" /f", @SystemDir, @SW_HIDE) very strange With or Without CMD /c (@comspec & " /c") I just can see the following screen shot. Did you compiled it in Console mode? Edited December 3, 2008 by Morteza Link to comment Share on other sites More sharing options...
Morteza Posted December 3, 2008 Author Share Posted December 3, 2008 if you want to hide that? why you just dont start regedit.exe instant with that parameters and hide it ?Very simple, because Regedit can not work with on the fly registry key created codes; It can work just with REG files. Link to comment Share on other sites More sharing options...
Danny35d Posted December 4, 2008 Share Posted December 4, 2008 (edited) very strange With or Without CMD /c (@comspec & " /c") I just can see the following screen shot. Did you compiled it in Console mode?No, I didn't. I'm using Scite as a editor and I press F7 to build the .exe file. When I press Ctrl+F7 which is compile and added the check mark to Create CUI instead of GUI EXE then I can see the same think as your screen shoot. Edited December 4, 2008 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line 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