Sign in to follow this  
Followers 0
sb1920alk

IniWrite as Admin User

5 posts in this topic

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?

Share this post


Link to post
Share on other sites



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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 :P

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0