ViciousXUSMC Posted April 22, 2015 Posted April 22, 2015 (edited) I am trying to collect the IMEI number off 52 devices as I set them up.I found the CMD: netsh mbn show interfaceThis works perfect but I want a way to log/copy this information so I created a .bat file. netsh mbn show interface > %userprofile%\desktop\rename.txtThis works but I wanted to wrap it in autoit so I can have the file be the computer name.I tried running the .bat file from autoit and tried @ComSpec and none of that works I keep getting an error"mbn show interface is not a recognized command" or something of that nature.I assume this has something to do with the start in location, or possibly because netsh has its own sub command shell so its taking the netsh command but then not passing the rest of the command properly. Not sure what it is but could use a bit of expert help for those who have already seen this and figured it out.Regards,Edit: one of my earlier attemptsRun(@ComSpec & " /k netsh mbn show interface > %userprofile%\desktop\rename.txt") While 1 If FileExists(@DesktopDir & "\" & @ComputerName & ".txt") Then Exit Sleep(200) FileMove(@DesktopDir & "\rename.txt", @DesktopDir & "\" & @ComputerName & ".txt", 1) WEnd Edited April 22, 2015 by ViciousXUSMC
jguinch Posted April 22, 2015 Posted April 22, 2015 (edited) Why not just this : Run(@ComSpec & " /k netsh mbn show interface > " & @DesktopDir & "\" & @Computername & ".txt") ? Edited April 22, 2015 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
ViciousXUSMC Posted April 22, 2015 Author Posted April 22, 2015 That would be my end goal, I was getting past the first issue before combining the pieces It will returns this in my .txt file:The following command was not found: mbn show interface.
Solution jguinch Posted April 22, 2015 Solution Posted April 22, 2015 Try this : Run(@WindowsDir & "\sysnative\cmd.exe /c netsh mbn show interface > " & @DesktopDir & "\" & @Computername & ".txt") Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
ViciousXUSMC Posted April 22, 2015 Author Posted April 22, 2015 That seems to be the ticket, so can you help me wrap my head around the actual issue and why this solves it?
jguinch Posted April 22, 2015 Posted April 22, 2015 With a x64 OS, there are some redirected folder and registry keys when you use a x64 program. With a x86 program (like an au3 script running in x86 mode), @SystemDir or @ComSpec (ore else) are redirected to the SysWOW64 environement (c:windowssyswow64), even if you refer to c:windowssystem32. In you case, the netsh.exe running is the x86 one (located in c:windowssyswow64, witch seems to have differents options than the netsh.exe located in c:windowssystem32. You can refer to the x64 System32 directory by refering to c:WindowsSysnative. An second way could be to disable the folder redirection by calling the WinAPI Wow64DisableWow64FsRedirection function. An third way could be to compile your script in x64 mode. DllCall('kernel32.dll', 'bool', 'Wow64DisableWow64FsRedirection', 'ptr*', 0) Run ( @ComSpec & " /k netsh mbn show interface") For more explaination about the folder redirection, you can read this MSDN article : https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187%28v=vs.85%29.aspx In fact, Sorry if it's not clear... Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
ViciousXUSMC Posted April 22, 2015 Author Posted April 22, 2015 No it is clear as I knew about the redirection, I have run across it before with other things (and the HKLM64 issue with registry as well) I just did not realize that is what was happening here, I had no idea netsh had two different executables.Thanks for the explanation and the appropriate fixes.
jguinch Posted April 22, 2015 Posted April 22, 2015 Glad to help Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now