run vbscript mhta [closed] - vbscript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i want to run vbscript from mhta

mshta "vbscript:window.close(msgbox("test"))"
WScript or CScript script hosts are not able to run a script if it is not stored in a file. But you can use mshta and the vbscript: protocol to run simple commands.
Anyway, for this case, it is easier to use
msg console "test"
edited to adapt to comments
i've being testing. vbscript parser in the mshta url has to face a lot of limitations. And problems with spaces, concatenation of commands with :, problems with procedure calling as a function but you can not use call keyword as a space is required, ....
The only stable, "easy" way of doing it is to prepare the vbscript to execute as a string, with no spaces inside it, and use the execute method to run it
mshta "vbscript:window.close(execute("msgbox"&chr(32)&"""test"":msgbox"&chr(32)&"""this"&chr(32)&"should"&chr(32)&"work"""))"
mshta "vbscript:window.close(execute("server=CreateObject(""WScript.Shell"").RegRead(""HKEY_CURRENT_USER\Volatile"&chr(32)&"Environment\LOGONSERVER""):For"&chr(32)&"i=1"&chr(32)&"to"&chr(32)&"3:msgbox"&chr(32)&"i"&chr(38)&"server:next"))"

Related

Bash - How to share constants between scripts? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is there a way to make it so that there isn't a list of constants at the top of every bash script i have? I have a lot of readonly constants for formatting and such but having them at the top of every single one of my scripts takes up space. Is there a way to make a separate script containing all of them and access it or something? or some way to clean it up?
Use a common script that you source in your other scripts.
E.g. source common.sh will execute that file and you may export variables there.
This is also how files like .bashrc and .bash_profile work, it is sourced when you execute bash (the latter when it is a login shell). When you change .bashrc, you can source it again in the running shell for the changes to take effect.

Batch file appears not to run and shuts down immediately [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am trying to run a batch file with the following code:
set dirA=C:\SE_BulkUnzipTarGzipFiles\WinRarSamples\In
set dirE=C:\SE_BulkUnzipTarGzipFiles\WinRarSamples\OutPut
set dirC=C:\SE_BulkUnzipTarGzipFiles\WinRarSamples\Processed
The batch file does not run and shuts down immediately and I cannot figure out what is wrong.
Couple of things you need to understand. When we set variables, we typically enclose them in double quotes in case there are whitespace, which after the whitespace, the next field is seen by cmd as a new command and you will get some errors you would not want, such as the infamous "Is not recognised as an internal command on batch file` error, so we would therefore rather do this:
set "dirA=C:\SE_BulkUnzipTarGzipFiles\WinRarSamples\In"
set "dirE=C:\SE_BulkUnzipTarGzipFiles\WinRarSamples\OutPut"
set "dirC=C:\SE_BulkUnzipTarGzipFiles\WinRarSamples\Processed"
The code then does exactly what you told it to do and that is to simply set variables %dirA% %dirE% and %dirC% with the respected values.
Now to see a result, you need to do something with those variables, perhaps we echo them?
#echo off
set "dirA=C:\SE_BulkUnzipTarGzipFiles\WinRarSamples\In"
set "dirE=C:\SE_BulkUnzipTarGzipFiles\WinRarSamples\OutPut"
set "dirC=C:\SE_BulkUnzipTarGzipFiles\WinRarSamples\Processed"
echo %dirA%
echo %dirE%
echo %dirC%
pause
Your script runs, but it finishes almost immediately.
If you add a pause command at the end, the window will stay open until you press a key.

Quotes in VBScript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Due to system integrity I can't use " in my VBScript. Additionally escaping the quotes won't work.
Is there a possibility to use different quotes? Single quotes don't seem to work.
Sorry, string literals in VBScript use double quotes. There is not any alternative quoting syntax.
But, of course, you can change this (with quotes)
Dim test : test = "test"
into this (without quotes)
Dim test : test = Chr(116) & Chr(101) & Chr(115) & Chr(116)

How to write a file in ruby without a terminating newline [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
For debugging purposes, I want to alter a rake test so as not to end a saved file with a newline.
I don't know ruby. How do I do this? (file.print doesn't seem to work.)
Not clear what you are doing, but since you tried file.print, it looks like you have access to what is to be printed. Let's say this is string. My guess is that string already has a newline character. Then do:
file.print(string.chomp)

Identifying and adapting unix-"isms" to the Windows command prompt [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
In the Python Pyramid tutorial, I encountered this phrase:
"Windows users will need to adapt the Unix-isms below to match their environment."
It appears to relate to the "Export" command, but I am not entirely sure. The question therefore, is how do others go about this process of identifying and adapting "Unix-isms"? My only method so far is to see what isn't recognized, and obviously that could be due to different reasons.
Regarding research, I may have found a paywalled explanation for export specifically, but I'm sure there are better resources for adapting these commands.
Thank you!
The $ symbol is a Unix prompt
The ; is a command separator
export sets sets an environment variable, similar to setx
PATH=/path/to/tutorial_workspace/venv/bin:$PATH is modifying the PATH environment variable, similar to PATH=/path/to/tutorial_workspace/venv/bin;%PATH%
which searches the PATH for a program and returns its location.

Resources