Jump to content

PC rebooter script not working on some of Win 7 machines


Raj83
 Share

Recommended Posts

Hi All,

I am getting an issue with one of our script in AutoIT, RunASWait command seems not working in some of the Win 7 machine.

$Return=RunAsWait($UserArray[2],$UserArray[1],$Pass,0,@ComSpec & " /c " & Chr(34) & $BatchFile & Chr(34),"C:\Temp", @SW_SHOW)

I have tried on different machine with same user privileges, but it works on some machines and did not work on some. it dosen't throw any error but remote machine is not rebooting.

Please advice if any thing is funny in this code.

Regards,

Rajesh Suyal.

Link to comment
Share on other sites

all i can think of is, try and disable UAC and DEP...

Could be some interference OR...that its a 64-bit OS...happened to me with some utilities i have compiled as 32 bit. After converting it to 64-bit, it worked ( with the EXACTLY same commands/functions )

Edited by MariusN
Link to comment
Share on other sites

$Return=RunAsWait($UserArray[2],$UserArray[1],$Pass,0,@ComSpec & " /c " & Chr(34) & $BatchFile & Chr(34),"C:Temp", @SW_SHOW).

Also, I would like to add here is if I click on the batch file (highlighted in red above) manually it runs ok, but it doesn't with above command on some windows 7 machine.

Link to comment
Share on other sites

Hi,

Can anyone provide me some hint of doing same thing by anyother way, here I am creating a batch file of reboot command for many machines and running them in one go. batch file created successfully and it doesn't work on some of the windows 7 machines. manually clicking on batch file runs fine.

Link to comment
Share on other sites

Is the batch file just rebooting the computer or does it do other things before the reboot? Because there's an internal AutoIt command for rebooting look up Shutdown in the help file.

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 Gude
How 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

Link to comment
Share on other sites

yes, infact its working fine on all WinXP machines, but doesn't work on some Windows 7 machine. doesn't give any error but nothing happens if you look at the other end.

I am running the batch file via AutoIT code below.

$Return=RunAsWait($UserArray[2],$UserArray[1],$Pass,0,@ComSpec & " /c " & Chr(34) & $BatchFile & Chr(34),"C:Temp", @SW_SHOW).

On investigation I can confrim that above command is failing as if I click on batch file, it reboots the remote machine successfully.

$UserArray[2] : Admin User on both local as well as Remote machine.

$UserArray[1] : Domain.

$Pass : Admin password.

I am running with Admin Username and Password. Any Clue..

Link to comment
Share on other sites

try with #RequireAdmin flag ?

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • 3 months later...
  • Moderators

Have you tried just doing it in pure AutoIt, rather than running an AutoIt script to call a batch file? Something like this?

ShellExecute("shutdown.exe", '-r -m \\VDTPXP-23-13 -c "Rebooted using PandL Rebooter by rsuyal"')

If you need to do the RunAs, you could always try it without the batch file as well:

RunAsWait($UserArray[2], $UserArray[1], $Pass, 0, 'Shutdown -r -m \\VDTPXP-23-13 -c "Rebooted by me"', @TempDir, @SW_SHOW)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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...