When I double-click my .vbs file in Windows, it will start the wscript.exe process, but doesn't appear to execute anything. Even a simple "Hello World" script doesn't do anything—not even an error message from an invalid command. I'm using Windows 10.
Related
When I use slmgr /skms <URL> | cmd command in PowerShell it shows me a pop up that I must press the ok button after that I run slmgr /ato | cmd and again shows me another pop up that I press the ok button.
I don't want to press the ok button manually, can anybody help me if there is a solution for it, please?
I just disabled the uac in windows, but it does not help me.
What you are looking for is cscript. By just executing a vbs script file, output gets sent to dialog boxes, which need your interaction.
Using cscript, the desired output gets printed to your current stdout:
cscript C:\Windows\System32\slmgr.vbs /ato
That doesn't have anything to do with UAC and you might consider re-activating it.
But why is that?
slmgr is not a command nor is it an executable in windows. It's a script file written in VBScript. VBScript is a kind-of scripting version of VB, So it's good for your peace of mind not to deal with it too much.
If you type in slmgr /skms, what windows does is looking for a file named slmgr in its search paths (%PATH%), finding C:\Windows\System32\slmgr.vbs and deciding that, as its a .vbs file, executing wscript.exe with the file path and your arguments as parameter is the right thing to do.
WScript is the default interpreter for vbs files and just interprets the file and executes its code. On the other hand, there is cscript for console scripts.
If the author of the .vbs file decides to write a message to the user of their script, they usually use a statement like
Wscript.Echo "Hello, World!"
And thats where your confusion starts:
Executing this script in cscript means that Hello, World! is written to the console. (That's what you want to do)
Executing the same script using wscript renders a message box with a OK button. You can easily reproduce it yourself by creating a vbs file with the above statement.
The difference between cscript and wscript is also discussed in this question:
Difference between wscript and cscript
I've got a simple exe application that writes in a file the first argument with which it gets called, so from command line I can do
MySimpleApp.exe "FOO"
and in the SimpleFile.cfg I get "FOO".
If I try to run this batch (it's in the same folder of the app)
set mypath=%~dp0
%mypath%MySimpleApp.exe "FOO1"
%mypath%MySimpleApp.exe "FOO2"
%mypath%MySimpleApp.exe "FOO3"
every time MySimpleApp gets called Windows ask the administrator permissions to execute the app. I thought that I could just run the batch as administrator, but even if I get no UAC prompt the application doesn't execute.
Is there some option or command that I must use to call an exe file when the batch is launched in administrator mode?
Filenames with spaces MUST be enclosed in quotes.
Always tack a pause at the end of a batch to see how it is interpreting your commands. And likewise if using Echo Off turn it on. Hiding information from yourself about YOUR error is not wise.
So
C:\Users\FirstName LastName\Desktop>C:\Users\FirstName LastName\Desktop\MySimpleApp.exe "FOO3"
'C:\Users\FirstName' is not recognized as an internal or external command,
operable program or batch file.
In Windows 7 (and other versions), a batch (.CMD) file can contain the START command to run other executables without pausing the current batch execution. (similar to & in Unix). Under normal conditions, the program runs and the CMD file immediately exits.
I'm trying to start an executable from a CMD, and have it behave exactly as if it were started from a direct shortcut. The basic flow of the CMD script is:
...{check pre-requisites}...
start "MyProg" "C:\Program Files (x86)\MyProgram.exe" "Param1" "Param2"
...{handle errors}...
The Start command is working, but the started executable MyProgram.exe does not have its normal icon on the system's taskbar. It is the "blank sheet of paper" icon instead of the application's.
Is there any way to set the Windows taskbar Icon to that of the executable that is started?
Microsoft provides a number of parameters, but none are related to the icon.
I'm making a application in python from Windows. When I run it in the console, it stops, shows an error, and closes. I can't see the error becase its too fast, and I can't read it. I'm editing the code with IDLE (the program that came with python when I instaled it), and when I run it with the python shell, there are no errors. I would run it from IDLE, but when I use the console, it has more features.
I don't know why this is happening. I need your help.
Run the program from an already-open terminal. Open a command prompt and type:
python myscript.py
For that to work you need the python executable in your path. Just check on how to edit environment variables on windows, and add C:\PYTHON26 (or whatever directory you installed python to).When the program ends, it'll drop you back to the CMD windows prompt instead of closing the window.Add code to wait at the end of your script. Adding ...
raw_input()
... at the end of the script makes it wait for the ENTER key. That method is annoying because you have to modify the script, and have to remember removing it when you're done.
Run your program from a Windows command prompt. That will not automatically close when the program finishes.
If you run your program by double-clicking on the .py file icon, then Windows will close the window when your program finishes (whether it was successful or not).
Create a text file in the program directory i.e. wherever your script is located. Change the extension to .bat for example text.bat. Then edit the text file and write:
python main.exe
pause
Now you can run the program without typing into the command console by double clicking the bat file, and the console window will not close.
I'm running a script from the cmd prompt. This script opens another cmd prompt and runs another batch file there. I want to wait for the error code and then send it back to the original cmd window. Is there a nice way to do this without writing the error code to a file?
Thanks,
Li
If I inderstand you correctly, you want this solution. It solves the problem of returning error level to the calling script from the script that was run in a separate cmd session.