Knoffelstokkie Posted October 4, 2010 Posted October 4, 2010 Hi guys, I'm very new to AutoIt, so new that this will be my 1st attempt at scripting using it. I need to install a new app on a whole bunch of pc's and most user don't have admin rights. I wrote a batch file that will map a drive and install the app and then disconnect the drive and I've been trying to get it to run under my admin account without any luck. please have a look at what I have so far and make some suggestions Runas ( "username", "domain", "password", "batfile.bat" [, "c:\" ] ) regards Me
czardas Posted October 4, 2010 Posted October 4, 2010 Have you tried removing the square brackets? operator64 ArrayWorkshop
BrewManNH Posted October 4, 2010 Posted October 4, 2010 The items with the brackets around them in the command lines are shown that way to indicate that they are optional, you shouldn't use the brackets in the actual commands when using them. Just write that line as : Runas ( "username", "domain", "password", "batfile.bat", "c:\" ) instead. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 Thanks for the reply guys but now it just does nothing. I converted it into an .exe and when I run it on any pc nothing happens.
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 (edited) ok, so I've decided to try this a bit differently DriveMapAdd("W:", "\\servername\share", 0, "domain\username", "password") Runas( "username","domain","pass","batfile.bat","W:" ) It maps the drive but the batch file never tries to run after that, any ideas? all the batfile does is this msiexec.exe /i w:\eavbe_nt32_enu.msi /qb! REBOOT="ReallySuppress" ADMINCFG=w:\cfg.xml Edited October 5, 2010 by Knoffelstokkie
whim Posted October 5, 2010 Posted October 5, 2010 RunAs ( "username", "domain", "password", logon_flag, "program" [, "workingdir" [, show_flag [, opt_flag ]]] ) Missing 4th parameter ? HTH, whim
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 Missing 4th parameter ?HTH,whimThanks,I changed it to thisDriveMapAdd("W:", "\\servername\share", 0, "domain\username", "password")Runas( "username","domain","pass","2","nod32.bat","W:" )but still nothing
czardas Posted October 5, 2010 Posted October 5, 2010 You have passed the 4th parameter (logon_flag) to the function as a string, when it should be a number. Try removing the double quotes as shown. Runas( "username","domain","pass",2,"nod32.bat","W:" ) operator64 ArrayWorkshop
C45Y Posted October 5, 2010 Posted October 5, 2010 all the batfile does is this msiexec.exe /i w:\eavbe_nt32_enu.msi /qb! REBOOT="ReallySuppress" ADMINCFG=w:\cfg.xml would it be useful to forget the batch file altogether? _runDOS could issue the command much the same as the .bat would do. then we can rule out the bat file [which im thinking is the main problem here] http://twentylinesofcode.blogspot.comLittle apps n crap. can be fun
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 You have passed the 4th parameter (logon_flag) to the function as a string, when it should be a number. Try removing the double quotes as shown. Runas( "username","domain","pass",2,"nod32.bat","W:" ) yeah, I changed it but I still get no result, is there any other way you guys can think of doing this? I now have this DriveMapAdd("W:", "\\servername\share", 2, "domain\username", "pass") Runas("username","domain","pass", 4,"nod32.bat","W:") and the batch file contains this msiexec.exe /i w:\eavbe_nt32_enu.msi /qb! REBOOT="ReallySuppress" ADMINCFG=w:\cfg.xml
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 would it be useful to forget the batch file altogether? _runDOS could issue the command much the same as the .bat would do. then we can rule out the bat file [which im thinking is the main problem here] That sounds like a good idea, I'll give it a shot
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 would it be useful to forget the batch file altogether? _runDOS could issue the command much the same as the .bat would do. then we can rule out the bat file [which im thinking is the main problem here] Ok, _RunDOS confuses me completely, would you mind giving me some help in letting me do what I want done?
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 (edited) Ok, _RunDOS confuses me completely, would you mind giving me some help in letting me do what I want done?I think the "" in msiexec.exe /i w:\eavbe_nt32_enu.msi /qb! REBOOT="ReallySuppress" ADMINCFG=w:\cfg.xml might cause some issues int the _RunDOS command.also I was using runas so I can use my admin username and password on users pc's that don't have any install rights Edited October 5, 2010 by Knoffelstokkie
whim Posted October 5, 2010 Posted October 5, 2010 yeah, I changed it but I still get no result, is there any other way you guys can think of doing this? in view of: program: The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks)i would suggest Runas( "username","domain","pass",2,"W:\nod32.bat","W:" ) or whatever your full path is HTH, whim
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 changed it to Runas( "username","domain","pass",2,"W:\nod32.bat","W:" ) and still the same, only maps the drive and nothing else, is 2 the right flag option?
whim Posted October 5, 2010 Posted October 5, 2010 No idea (never used RunAS) but here's some thoughts 1) RunAs returns 0 on failure, so if that's the case, try other options ( maybe 0, interactive sounds like it might give you info ?) 2) If RunAs returns a valid PID your batch is at fault whim
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 No idea (never used RunAS) but here's some thoughts1) RunAs returns 0 on failure, so if that's the case, try other options ( maybe 0, interactive sounds like it might give you info ?)2) If RunAs returns a valid PID your batch is at faultwhimnope not getting any response from the program
BrewManNH Posted October 5, 2010 Posted October 5, 2010 Have you tried running the batch file just by itself on a computer while logged in with the required credentials? In other words, does the batch file actually work without trying to run it from AutoIt? Have you tried it using the APPDIR= command line switch? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
whim Posted October 5, 2010 Posted October 5, 2010 You're not being very clear, but assuming that ...nope not getting any response from the program... means that RunAs returns 0, have you seen this (again, in the helpfile)When running as an administrator, the Secondary Logon (RunAs) service must be enabled or this function will fail. This does not apply when running as the SYSTEM accountwhim
Knoffelstokkie Posted October 5, 2010 Author Posted October 5, 2010 Have you tried running the batch file just by itself on a computer while logged in with the required credentials? In other words, does the batch file actually work without trying to run it from AutoIt? Have you tried it using the APPDIR= command line switch?Yeah, batch file work perfectly on it's own and I can't find appdir in the helpfile
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