Voltrina Posted February 2, 2008 Share Posted February 2, 2008 hi, i'm new to autoit. i created my first script to start up several programs with different credentials. i did that with the example for RunAsSet in the help file, so it looks like this: RunAsSet('Peter', "MyPC", 'password') Run('"' & "D:\stuff\program.exe" & '"' & ' "' & @ScriptFullPath & '"', "D:\stuff") and so on... this works fine, but i need help with one program, which needs to be started with the "-startup" command. it works with shortcuts where the target is set to: "D:\stuff\program2.exe" -startup but i need it with different credentials.. and runasset doesnt work with shortcuts. can you help me? Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted February 2, 2008 Share Posted February 2, 2008 hi, i'm new to autoit. i created my first script to start up several programs with different credentials. i did that with the example for RunAsSet in the help file, so it looks like this: RunAsSet('Peter', "MyPC", 'password') Run('"' & "D:\stuff\program.exe" & '"' & ' "' & @ScriptFullPath & '"', "D:\stuff") and so on... this works fine, but i need help with one program, which needs to be started with the "-startup" command. it works with shortcuts where the target is set to: "D:\stuff\program2.exe" -startup but i need it with different credentials.. and runasset doesnt work with shortcuts. can you help me? Just add a -startup inside the quotes with a space separating the .exe or whatever. Link to comment Share on other sites More sharing options...
Voltrina Posted February 2, 2008 Author Share Posted February 2, 2008 i forgot to say, i already tried that and it says: The parameter is incorrect Link to comment Share on other sites More sharing options...
Squirrely1 Posted February 2, 2008 Share Posted February 2, 2008 Voltrina - please post the code that failed so someone can fix it. I noticed that the following code has a convoluted collection of quote marks: Run('"' & "D:\stuff\program.exe" & '"' & ' "' & @ScriptFullPath & '"', "D:\stuff") Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
thepip3r Posted February 2, 2008 Share Posted February 2, 2008 First off, your run looks terribly overcomplicated. you do know that the only parameter required for Run() is the path to the executable right? The other stuff might not be required. And if you're getting a parameter incorrect error, it may be from the program and not the run command. Try using ShellExecute() instead and see if you get the same problem. Aside from that, it sounds like you need to pass different credentials when using this prog?? if so, this is also easy. Seed two variables or arrays with user credentials. Pass the initial credentials to runasset() for when it sounds like a general majority of your program needs them and when you call the function or section of code that uses this special program, just reset runasset() with the new credentials and don't forget to re-reset the credentials back when you're done. My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume Link to comment Share on other sites More sharing options...
Voltrina Posted February 2, 2008 Author Share Posted February 2, 2008 okay so this(suggested above) fails to work. RunAsSet('Peter', "MyPC", 'Password') Run('"' & "D:\szamla\szamlazo.exe -startup" & '"' & ' "' & @ScriptFullPath & '"', "D:\szamla") the code is from the help file for autoit which is the following: ; This example will rerun itself with admin rights on using a local account ; Note on Vista this may not work as even though the user is admin it may ; not be elevated even after the RunAs call. In that case use #RequireAdmin ; at the top of the script. ; Are we already admin? If Not IsAdmin() Then RunAsSet('USER', @Computername, 'PASSWORD') Run('"' & @AutoItExe & '"' & ' "' & @ScriptFullPath & '"', @WorkingDir) Exit EndIf MsgBox(0, 'Message', 'Now running with admin rights.') Link to comment Share on other sites More sharing options...
Squirrely1 Posted February 2, 2008 Share Posted February 2, 2008 (edited) RunAsSet('Peter', "MyPC", 'Password') If StringInStr(@ScriptFullPath, " ") Then $quoted_path = @ScriptFullPath EndIf ;FileChangeDir("D:\szamla") ;Run("D:\szamla\szamlazo.exe -startup " & $quoted_path) ConsoleWrite(@CR&"D:\szamla\szamlazo.exe -startup " & $quoted_path&@CR) Run("D:\szamla\szamlazo.exe -startup " & $quoted_path, "D:\szamla") See if what is in the Console window after you run this, will work in a newly created shortcut. Otherwise you might need to wait until the program is running before you exit the script - if so, you might try RunWait instead of Run. Post all of your code so we can see better what you are trying to do. Edited February 2, 2008 by Squirrely1 Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
Voltrina Posted February 2, 2008 Author Share Posted February 2, 2008 well, i don't fully understand that, but it works thank you for the help!!! Link to comment Share on other sites More sharing options...
Squirrely1 Posted February 2, 2008 Share Posted February 2, 2008 (edited) Victory ! Of course you should be able to remove commented lines now - lines beginning with a semicolon. The parameters for the run command, especially the first should be as they would be in the shortcut "Properties" menu. In the Run command you embed quotes around any filepath that has space characters in it. The second parameter in the Run command, which occurs after the first comma "," in the functions syntax, corresponds to the folder "Run in" parameter of a shortcut, and shouldn't have embeded quotes no matter what, as far as I know. Keep on truckin' - you're learning. It's just a matter of trial and error, and studying forum posts, ecetera. In your code, that line that begins with ConsoleWrite, was just for debugging purposes, of course. Edited February 2, 2008 by Squirrely1 Das Häschen benutzt Radar 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