Jump to content

cmd prompt snafu Windows 7


Recommended Posts

I have a script that I use to change passwords on computers on a domain. It worked fine with XP, but on Windows 7, it has a problem. The script opens a command prompt with the run command, sends some text (a command) and "{Enter}". If I open a command prompt and manually issue the command, which involves using a PS tool, pspasswd, the command executes, whether or not I open the command prompt in administrator mode. When the script opens the command prompt, the command generates this error: "pspasswd' is not recognized as an internal or external command, operable program or batch file.

It's driving me nuts. If I copy and paste the command from the script into my DOS box, it executes. If the script opens the box, it fails.

Please help, and thanks.

Meds.  They're not just for breakfast anymore. :'(

Link to comment
Share on other sites

Use the Run command to run the program instead of trying to use Send with the console.

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

I think the PS tools are designed to be used with a command prompt but I can try using ShellExecute with the commands as the argument. But it will have to wait until tomorrow. I go home now. :D

Thanks for the quick reply, BrewManNH

Meds.  They're not just for breakfast anymore. :'(

Link to comment
Share on other sites

OK, I'm beginning to mature in my dislike of Windows 7. Using ShellExecute, my error message is "Windows cannot find 'C:\Windows\System32\pspasswd.exe'. Make sure you typed the name correctly, and then try again." Of course, the path and filename are correct. I'm beginning to think that I'm going to have to change passwords manually (that is, manually open the command prompt and copy and paste the command from my script.)

Does anyone know the secret to scripting pstools functions on Windows 7? I'm about out of ideas.

Thanks

Meds.  They're not just for breakfast anymore. :'(

Link to comment
Share on other sites

Don't put the files in system32 or SysWow64, because depending on how you compile your script it's going to look in system32 if it's 64bit, and sysWOW64 if it's 32 bit. Try to keep your files in a neutral location so that folder redirection doesn't happen.

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

BrewManNH pulls a rabbit out of his hat! When I put pspasswd.exe in Program Files (x86) and modified the path in my ShellExecute script, it works like a charm. The ps tool opens a command prompt, changes the passwords as directed, and even closes the DOS window when it's finished. I'm puzzled that given the path when the ps tool was in system32, Windows couldn't find the file. There must be special security on the system32 folder to keep "foreign" executables from running from there. Much thanks, BrewManNH, I doubt I would have thought of that. I owe you a pizza and a beer. :D I now have a script that works better than the one I was using with my XP machine. Thanks again, BrewManNH.

Meds.  They're not just for breakfast anymore. :'(

Link to comment
Share on other sites

The problem is because of folder redirection on x64 operating systems. Just because it's in Windowssystem32 doesn't mean that the script is looking in there. If the script is compiled as an x86 executable, any call to a program in system32 is getting redirected to sysWOW64 behind the scenes. There are workarounds for this, if you're really interested you could do a search of the site for "folder redirection", but it's easier to avoid the whole 64/32 bit problem by putting your programs somewhere that this doesn't affect.

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