sb1920alk Posted October 1, 2008 Share Posted October 1, 2008 I thought this would be easy, but I've run out of ideas. I need to change a value in an ini file while the logged in user running the compiled script is not an admin and the ini file is in a folder that is read-only to non-admins. I even tried compiling a second script that does nothing but edit the ini, then used RunAs to call the exe as an admin. I have a workaround for the current situation using the admin control panel that created the ini file, but it's a cumbersome script (send these keys, wait, send more keys, etc.)...it would be much quicker to edit the ini file directly. Any ideas? Link to comment Share on other sites More sharing options...
rudi Posted October 1, 2008 Share Posted October 1, 2008 Hi. If the user knows an account with admin rights, use #requireadmin if not, use something like If Not IsAdmin() Then Run("runas /user:ClearTextAdminUSerName ClearTextPassword " & @ScriptFullPath) Exit Else ; do your ini changes here EndIf Regards, Rudi. In case you have ZENworks available you can distribute it to run "as secure system" do to what you need directly. Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
sb1920alk Posted October 1, 2008 Author Share Posted October 1, 2008 Hi. If the user knows an account with admin rights, use #requireadmin if not, use something like If Not IsAdmin() Then Run("runas /user:ClearTextAdminUSerName ClearTextPassword " & @ScriptFullPath) Exit Else ; do your ini changes here EndIf Regards, Rudi. In case you have ZENworks available you can distribute it to run "as secure system" do to what you need directly. Regards, Rudi.The end users do not know the credentials for an admin account, but I tried it anyways myself. I also tried the second technique, but the ini value remains unchanged. I've never heard of ZENworks. Link to comment Share on other sites More sharing options...
rudi Posted October 8, 2008 Share Posted October 8, 2008 I've never heard of ZENworks.ZENworks is a configuration, management and SW distribution solution of Novell. It's very comfortable, scalabe and reliable. Current version is ZENworks Configuration Mangement 10.I use it whenever my autoit scripts need 1.) admin rights and 2.) have to be distributed to a larger group of PCs Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
ken82m Posted October 8, 2008 Share Posted October 8, 2008 (edited) This is how I've done it at work. Basically your running the script again to execute your INIWrite. But this second instance is running with the admin account and exits when it's done. To test this put your account info and compile it. This won't work unless you run it from a compiled exe. Kenny If $CmdLine[0] > 0 Then If $CmdLine[1] = "/ChangeINI" Then ChangeINI() Exit EndIf If RunAs("administrator", @ComputerName, "admin password", 0, @ScriptFullPath & " /ChangeINI") = 0 Then MsgBox(4096,"ChangeINI", "RunAs Failed") Exit EndIf Func ChangeINI() ;commands to change ini MsgBox(4096,"ChangeINI", "ChangeINI File Running") EndFunc Edited October 8, 2008 by ken82m "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." 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