Jump to content

Possible issue with RunWait() ???


Go to solution Solved by JLogan3o13,

Recommended Posts

I'm trying to use RunWait to execute the Windows command NLTEST. I need to determine what Active Directory site the machine is a member of. So I'm testing, and I can't get any output to show up in my redirection file. Here's the command I used:

Runwait(@ComSpec & " /c nltest /dsgetsite >" & @TempDir & "\dsgetsite.txt",@TempDir,@SW_HIDE)

When I look in my %temp% folder, I see a dsgetsite.txt file, and it is 0 bytes long. There's no information in it. If I execute the command from a Windows command line, I get the expected output.

Now, here's the kicker... if I compile the script as 64 bit and run it, the text file gets output logged in it.

I'm running Windows 8.1 Update 1 and I've tried with AutoIT 3.3.8.1 and 3.3.10.2 with the same results.

Any ideas?

Thanks!

Link to comment
Share on other sites

Update to issue:

I just tried running the 32 bit compiled script on Windows 7, and it works. So there's some type of shenanigans going on with Windows 8.1 Update 1.

Fortunately, I'm the only one in the company running Windows 8, so that shouldn't be a problem for my script. I'll just need to test and debug in a VM... oh well!

 

Link to comment
Share on other sites

When I run that command on my x64 Win 7 I get this message, in the console, running it as an x86 process.

 

'nltest' is not recognized as an internal or external command, operable program or batch file.

NOTE: I was able to get that message because I removed the @SW_HIDE and changed /c to /k in the RunWait line.

This is why I always recommend that you NEVER use /c and/or @SW_HIDE until your script is working the way you want it to. Hiding error messages from yourself just makes it so that you'll never know why you screwed up.

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

  • Moderators
  • Solution

Or just do something like this:

$AD = ObjCreate("ADSystemInfo")
    MsgBox(0, "", "Current site name: " & $AD.SiteName)

"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

This is perfect! Thanks JLogan3o13!

@BrewManNH:

I don't know why your nltest isn't working. It's a standard tool in Windows. Maybe it's only there if you're joined to a Microsoft Active Directory. However, the issue for me isn't that the command is missing. It's how Win8 is handling the run. It works fine as a compiled 64-bit script. It does NOT work as a compiled 32-bit script. Either one works fine under Win7. Odd...

Edited by wosteen
Link to comment
Share on other sites

I tested this on a Windows 7 Professional joined to an AD domain.

If you look in windowssyswow64 you'll see that there is no program nltest.exe. In windowssystem32 there is.

As AdamUL mentioned it's a folder redirection issue which is why it works when run as an x64 process and fails when run as an x86 process on an x64 OS. If the OS is x86 then there is no redirection going on, and the file is found in system32.

EDIT: BTW, my main point was the note and what I wrote below it. You need to make sure everything is working before you start hiding the inner workings from yourself. You would have seen the same thing I did if you did it the right way.

Edited by BrewManNH

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

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