Jump to content

runas


Recommended Posts

Hello,

I need to run a batch file to change power settings with the credentials of an administrator and am not sure of what I need to do.

I tried to create an exe file using the AutoIt sample script but have not had any success.

I welcome any ideas.

Thanks

Link to comment
Share on other sites

... I need to run a batch file ... ... with the credentials of an administrator ...

This worked for me on an XP SP2 VM

; Fill in the username and password appropriate for your system.
Local $sUserName = "username"
Local $sPassword = "password"

; Run a command prompt as the other user.
RunAs($sUserName, @ComputerName, $sPassword, 0, "C:\Temp\1.bat", @SystemDir)
1.bat contained one line:

pause

Task manager showed cmd running under admin credentials when run by a limited user.

Edit: Welcome to the forum :-)

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

This worked for me on an XP SP2 VM

; Fill in the username and password appropriate for your system.
Local $sUserName = "username"
Local $sPassword = "password"

; Run a command prompt as the other user.
RunAs($sUserName, @ComputerName, $sPassword, 0, "C:\Temp\1.bat", @SystemDir)
1.bat contained one line:

pause

Task manager showed cmd running under admin credentials when run by a limited user.

Edit: Welcome to the forum :-)

Link to comment
Share on other sites

Thank you very much for taking time to respond to this.

I am obviously not very knowledgeable about scripting. I should also be more specific.

I am trying to run this batch file using a GPO login script. My problem is that many of the

users on our network do not have privileges that allow this.

I will try to study your response to see what I can figure out.

Thank you again for the help :)

Link to comment
Share on other sites

Please keep in mind that there is a per-user setting and also a per-machine setting for the power configuration. If you use "runas" in your script the power scheme of your logged on user will not be changed! You'll write changes to the profile of the user that was stated in the runas command.

Maybe here's a good starting point for you: How to use Powercfg.exe to create a Group Policy object for power schemes in Windows XP

If you're up to a windows 2008 domain level you can control everything via group policy without scripting anything.

Link to comment
Share on other sites

Hello,

It is a domain. I really should be more specific about my questions.

Do you know what the syntax would be to create an exe file with AutIt to run another batch file?

I have tried the example in the help file but I am apparently doing something wrong.

Here is what I have.

runAsWait ( "user", "domain", "password", 1, "myfile.bat", "\\server\path\share" )

I was hoping that by setting up my GPO to point to this file, it would then execute the batch file when a user logs in, but with

administrative privileges.

Thank you very much for the help on this.

Link to comment
Share on other sites

Hello,

Thanks for the link. I have actually tried this and for some reason I have not managed to make this work.

I suppose I have not set it something up correctly because even though I have my GPO set to run the login script visible,

I never see an indication that it runs, and the power setting appear to be unchanged.

I am using the script provided by the article. I am a little unsure of the line that says.

@echo off

net use x: \\domain_DNS_name\netlogon

What should I put in the place holder that says "domain_DNS_name" ?

Is that the domain, like mydomain.com, or the actual server name? I also have multiple domain controllers,

and since this gets replicated to all, should I make that part say %logonserver% ?

Thank you for taking your time to help.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...