Sign in to follow this  
Followers 0
Raj83

PC rebooter script not working on some of Win 7 machines

17 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thanks alot for your response.

I checked the UAC and DEP setting is same on both the mahines, also, both machines having 32-Bit Windows 7 OS. can you advise how can I compile it to 64-bit.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

batch file contains only below;

shutdown -r -m VDTPXP-23-13 -c "Rebooted using PandL Rebooter by rsuyal"

EXIT 45

Share this post


Link to post
Share on other sites

the internal command is for Shutdown/reboot local machine. I want to reboot remote machine.

Share this post


Link to post
Share on other sites

In the batchfile you posted, the -m VDTPXP-23-13 is a reference to the computername. Does it match the computer you are trying to reboot?

Share this post


Link to post
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..

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

try with #RequireAdmin flag ?

Yes, I have already tried, but no luck. also check UAC on both the machine (where it's running fine and where it's failing) and its also same.

Share this post


Link to post
Share on other sites

When you run the script, do you get an error?

Share this post


Link to post
Share on other sites

I always use '-f' with shutdown.exe to force it.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites

This issue still haunt's me, does anyone have found any reason for the script now working.

Share this post


Link to post
Share on other sites

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)

√-1 2^3 ∑ π, and it was delicious!

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