autohotkey script & batch file problem ...
Looking for someone who knows about autohotkey and batch files to help me out with something.
I want to run a batch file in an autohotkey script - no problem doing that at all. Simple as a run command.
But the problem is that the command in the batch file requires to be run as administrator (usually I would right click on the file and choose run as administrator, and then click yes to the UAC prompt). If it doesn't run as administrator, the batch file runs but doesn't do anything.
I don't really need autohotkey to run as administrator (I have found instructions for that) as I won't be sending any keystrokes to the batch file ... i just want the batch file to run as administrator.
Any suggestions? I have a feeling I haven't explained this very well as I am very tired so please ask for clarification.
_________________
Female. Dx ASD in 2011 @ Age 38. Also Dx EDD/BPD
What OS?
Not exactly sure what you're trying to do, but AHK has a RunAs command that will make all following Run commands start with the credentials you enter with RunAs. Other than that there's workarounds such as creating a shortcut to the batch file and setting the shortcut to Run as Administrator (not in the compatability tab but click the 'Advanced' button and set it in there).
_________________
There's something inside me'n'I know it's good...
But understanding, it's misunderstood. - D.A.D.
I registered just to help you out with this. I work in an enterprise environment as helpdesk. We use a lot of runas commands.
We work with windows, so I assume you're using windows.
What you want to do is create a new batch file that points at your other batch file, it will contain the following line
runas /u:username script.bat
where you replace username with the name of your admin account and script.bat with the name of your script, it will then run that script as the user you define.
I got the impression he didn't want to type in a password every time. He could use the /savecred option depending on OS. But that can be a bit of a security risk.
_________________
There's something inside me'n'I know it's good...
But understanding, it's misunderstood. - D.A.D.
I use the following javascript code to elevate my batch files.
Save as Elevate.js, then call it thus:
elevate NameOfBatchFile
// elevate.js -- runs target command line elevated
if (WScript.Arguments.Length >= 1) {
Application = WScript.Arguments(0);
Arguments = "";
for (Index = 1; Index < WScript.Arguments.Length; Index += 1) {
if (Index > 1) {
Arguments += " ";
}
Arguments += WScript.Arguments(Index);
}
new ActiveXObject("Shell.Application").ShellExecute(Application, Arguments, "", "runas");
} else {
WScript.Echo("Usage:");
WScript.Echo("elevate Application Arguments");
}
| Similar Topics | |
|---|---|
| What is DOS batch programming good for? |
28 Feb 2010, 7:34 pm |
| batch delete tiny files |
20 Apr 2014, 10:03 pm |
| A Trick: Batch Processing VS Exec Dysfunction |
25 Apr 2012, 9:26 am |
| a free program to manually batch edit ID3 tags? |
12 Jun 2011, 7:01 pm |
