'netcfg.exe' is not recognized as an internal or external command, operable program or batch file." when call through vbscript - variables

i am trying to execute netcfg.exe /U ms_pacer etc to uninstall some bindings to the network adapter. now everytime i pass the command through vbscript the command prompt throws an error saying 'netcfg.exe' is not recognized as an internal or external command, operable program or batch file.
if i put it in a batch file and double click on it it runs fine. but again if i execute that batchfile through a .run in vbscript it gives the same error. i read somewhere that it could be environment variable issue, but tried setting environment, looks good but the command keeps throwing the error again and again. tried it in powershell but no go, please someone guide.

Ok found the answer, when running a 32 bit compiled application which needs to access another native windows application there is a catch. though windows has provided a set of 32-bit set of native applications in a 64 Bit OS, but has not changed names of files, and have been relocated in another folder i.e. %windir%\SysWoW64\ , now everytime a 32 bit application tries to access c:\windows\system32 on a 64 bit, it gets redirected to %windir%\SysWoW64\, now if one wants to refer to 64 bit native application then do %windir%\Sysnative

Related

'C:\Users\User' is not recognized as an internal or external command, operable program or batch file

When I using VS code remote SSH connection, it always fails to connect and warning me "'C:\Users\User' is not recognized as an internal or external command, operable program or batch file."
I guess the issue is the path "C:\Users\User" contains space, and the full path should be something like "C:\Users\User Name...", but I don't know how to suppress and add the escape character to space.
Can anyone help me to resolve the problem? Many thanks!
Other information:
Operating system: Windows 10.
I have installed OpenSSH and I can connect to the remote server using windows PowerShell or git bash.
The version for VS code is 1.43.0 and extension is 0.50.0.

XOpenDisplay(NULL) fails to connect to X

I was given a fairly large program to compile and run with extremely vague instructions on how to properly configure my system and install the program. I was told to use a Windows, install Cygwin, navigate to the program's base directory, and type "make". I installed Cygwin on a 64-bit Windows 7 in C:\cygwin64 as the main user (I also installed all of the default packages, plus a few extras) and then ran the makefile included with the program (this worked with no problems). When trying to run the executable with a required file argument, I was simply given the error message "cannot connect to X server." Upon examination of the code, it appears that this error was caused by a line setting display=XOpenDisplay(NULL) and then exiting when this resulted in display == NULL. Earlier, "display" had been declared as a variable of type Display. Is there any way I can get the program to connect to the X server? I have been assured that the installation of the program is extremely easy, but I'm not so sure... Thanks in advance.

cmd.exe will not recognize command

I have a vb.net application that runs cmd.exe as the following:
Dim Port1 = CreateObject("WScript.Shell")
Port1.Run("cmd.exe")
Port1.Sendkeys("telnet ip address")
Port1.Sendkeys("{Enter}")
System.Threading.Thread.Sleep(6000)
When the cmd runs the sendkeys a error shows
"'telnet' is not recognized as an internal or external command,
operable program or batch file."
I closed the cmd window, opened another cmd, and typed in the command with not problems.
I need cmd to run in the vb.net and not as a separate file.
Running the vb.net in Microsoft visual studio Ultimate 2013.
Update: Can anyone tell me why it is doing the same thing when i move the app to another computer and try to run it?
You have to enable telnet on the computer by going to start > control panel > programs and features > turn windows feature on or off > check telnet client or typing optionalfeatures in run and checking telnet client. The command should execute successfully after that.
Either Telnet is not installed on your computer (it's not installed by default on any modern Windows versions as far as I know), or it its installation directory not in the PATH environment variable.
Either add it's install directory to PATH, or specify the full path to telnet.exe in the arguments to cmd.exe.
CMD runs commands based off of System32 and .bat(batch) or .exe. You would have to create a .exe or a .bat and place it into System32 in order for the command to work.

VB.NET Process.Start failing

A problem that has been plaguing me for nearly a week now.
I am trying to get an install of IIS to take place through the command line in VB. I understand that i need to be setting up an Unattended xml script to call, but here is a fundamental bit that is confusing me:
If i run the command : ' start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer; ' it executes perfectly within CMD.exe.
If i add the command to a batch file and run the batch file, it runs perfectly.
If i call the command using : Dim myProcess As Process = Process.Start("cmd.exe", "/k start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;"), then it fails with an error of:
////////////////////////////////////////////////////////////////////////////////////////////////////////////
Operation failed with 0x8007000B ////
////
An attempt was made to run the program in an incorrect format ////
////////////////////////////////////////////////////////////////////////////////////////////////////////
If i call the batch file mentioned earlier, then i get the exact same error.
How can it work perfectly with the two first examples but fail when it is called through VB?
Thanks for any help!
Your VB.NET program is very likely to be running in 32-bit mode and will start the 32-bit version of cmd.exe. The one from c:\windows\syswow64 instead of the one from c:\windows\system32 that you used before. Getting BadImageFormatException starts to become likely.
Project + Properties, Compile tab, set the Target CPU to AnyCPU and untick the "Prefer 32-bit" option. On older versions of VS click the Advanced Compile Options button to get to the setting.

VB6 COM Object - only works when IDE is running?

I have an ancient COM object in VB6 that has been working fine until recently. (Don't they all). The only code change that has been made (as verified by svn) is the inclusion of a new string literal in an array.
The VB6 IDE compiles the object fine. When I hit Run|Start... and execute the following test vb script from the command prompt, the object works fine and I see the dialog boxes I expect:
dim o
set o = CreateObject("MyDll.MyClassName")
wscript.Echo "Testing object"
wscript.Echo o.HelloWorld ' runs a test method that returns "Hello World"
wscript.Echo "Done"
However, when I stop debugging in the IDE and attempt to run the same vbscript from the same command prompt, I get the error:
(ProgID removed for security reasons, but it is the same as in the script.)
Things I've tried:
I suspected that the DLL may have been registered and unregistered by VB when I start and stop the debugger, so I also tried registering the object with regsvr32 before running the test script. This has had no effect.
I also removed all references to the DLL from the registry, and re-registered the object. Same error.
I deleted the DLL and re-built it from VB (File|Make...) and re-registered the DLL. Same error.
Machine is Win7 Ultimate x64, object built with VB6.
Any suggestions?
And, no, unfortunately, rewriting the object in C# isn't an option.
Microsoft says it's some sort of dependency issue: http://support.microsoft.com/kb/194801
Because it's working when you run the object in the IDE this leaves you with four possibilities:
The ActiveX dll itself is not on the system path.
The ActiveX dll depends on something else which is not on the system path.
After registering the dll, it is somehow marked as requiring elevated security to run
After registering the dll, something it depends on requires elevated security to run.
I would try opening a command prompt as administrator then run your vbscript file that starts the object. If that works then it means the problem is either #3 or #4. If it doesn't, then it means #1 or #2.
You can eliminate #2 and #4 if the ActiveX dll has no external dependencies.
Next, I'd look in my event log to see if any other errors were logged by windows about this.
UPDATE
Just found another possible cause. If the ActiveX dll is 32-bit, then the script has to use the 32-bit version of the script engine to run; otherwise it will give this error because the default script engine (x64 on that machine) literally can't find the dll.
I believe if you use \windows\system32\cscript.exe to run your vbscript then you'll be good.
Well it definitely sounds like the issue because of 32bit dll.. The suggestion mentioned above is correct but the path is wrong.. try using the CSCRIPT from C:\Windows\SysWOW64..
Try registering the DLL with regsvr32.exe from %Windows%\SysWOW64. It is different than the regsvr32.exe in %Windows%\System32 (on a 64-bit OS).
See this SO posting.