Batch Posted April 23, 2004 Posted April 23, 2004 It appears that if you have a RunAsSet statement in your script, and then you try to use Run with the @SW_HIDE option, it will not be hidden: This works fine and is hidden: RunWait( "cmd /c cacls c:\temp /T /E /C /G users:C", "", @SW_HIDE ) RunWait( "cmd /c \\server\utils\psshutdown -t 600 -f -r -l", "", @SW_HIDE ) This doesn't have the windows hidden, I see the DOS window appear: RunAsSet( "user", "domain", "password" ) RunWait( "cmd /c cacls c:\temp /T /E /C /G users:C", "", @SW_HIDE ) RunWait( "cmd /c \\server\utils\psshutdown -t 600 -f -r -l", "", @SW_HIDE ) I have to run the cacls to set permission as well as the wonderful pstool psshutdown under an admin account, but they are not running hidden. I checked the help file and I don't see anything obvious that I'm missing, what the dealie?!
Batch Posted April 26, 2004 Author Posted April 26, 2004 Was it something I said? I've never posted something and had to wait this long for a reply, hehe, what's the deal?
scriptkitty Posted April 26, 2004 Posted April 26, 2004 actually I think it is how it is handled. Like a seperate command does the run as set part, and that part is being minimised/hidden. You run in to this with Dos Commands, if you run say: Run(@ComSpec &' /c notepad.exe','',@SW_HIDE) Sorry, I don't have a better answer for ya, but I don't know how microsoft does the runasset precisely. AutoIt3, the MACGYVER Pocket Knife for computers.
Valik Posted April 26, 2004 Posted April 26, 2004 My guess is that it's not a bug, but how Window's works. It probably has to do with the desktop the program is running in and/or whether or not Windows passes along the information to the application.
Developers Jos Posted April 27, 2004 Developers Posted April 27, 2004 Batch, I see the same behaviour and don't know why that is.... Heres a simple example: Opt ("TrayIconHide", 1);0=show, 1=hide tray icon Opt ("RunErrorsFatal", 0);1=fatal, 0=silent set @error $USERNAME = "Admin" ; local admin account name $PASSWORD = "password" ; local admin account psw RunAsSet($USERNAME, @ComputerName, $PASSWORD) $RC = RunWait(@ComSpec & " /c dir c:\windows\*.* /s", "", @SW_HIDE) MsgBox(0, 'test', $RC) A way arround it is to restart the batchfile after the runas and then do the command(s)... like this: Opt ("TrayIconHide", 1);0=show, 1=hide tray icon Opt ("RunErrorsFatal", 0);1=fatal, 0=silent set @error $USERNAME = "Admin" ; local admin account name $PASSWORD = "password" ; local admin account psw $RUN = 0 ; run indicator 1=first cycle uninstall 2=install new If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] If $RUN = 0 Then RunAsSet($USERNAME, @ComputerName, $PASSWORD) ; start the script program (itself) again but now in Adminmode...so all done tasks will run in Adminmode Run('"' & @ScriptFullPath & '" " 1"') If @error = 1 Then MsgBox(48, "Error", "cannot start the installation because you are not in Admin mode") EndIf Exit EndIf $RC = RunWait(@ComSpec & " /c dir c:\windows\*.* /s", "", @SW_HIDE) MsgBox(0, 'test', $RC) 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.
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