2

I have exe file called invis.exe, which is a converted vbs to and exe with this content:

  • CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

Using this I want to create invisible batch task with even new commands in (Click on batch - executes invis.exe cmd.exe "title Example"), so basically I just want to create batch which runs command in new invisible batch.

Vomit IT - Chunky Mess Style
  • 40,038
  • 27
  • 84
  • 117
Arty
  • 65
  • 5

1 Answers1

2

I just want to create batch which runs command in new invisible batch

Unless I misunderstand what you are trying to accomplish, you can make the logic of the VBS script accept the first argument, which will be the full path to a batch file, and this will ensure that that batch script runs hidden or silently.

This way you can make the batch script logic do whatever you want, and then you pass that script to the VBS script and that'll ensure whatever logic it runs will be hidden.

VBS Script Logic

Set Arg = WScript.Arguments
var = Arg(0)

Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & var & Chr(34), 0
Set WinScriptHost = Nothing
Set Arg = Nothing

Testing It

To test this you can run something like. . .

C:\folder\path\InvisibeArgTest.vbs "C:\folder\path\script.bat"

If you convert the VBS script to an executable file, then you'd use something like. . .

C:\folder\path\InvisibeArgTest.exe "C:\folder\path\script.bat"

Note: With this method, you can have just one VBS script or converted EXE and then you can program in the batch script logic to do whatever you want. You'd only need to pass that batch script full path into it as the first argument and it'll run whatever the batch script logic contains hidden. This way you have the flexibility to run any batch script with it or change the batch script logic you pass to it without needing to change the VBS logic or recompile the EXE or use another batch script. Keep it simple if it'll suffice.


Further Resources

Vomit IT - Chunky Mess Style
  • 40,038
  • 27
  • 84
  • 117
  • Well I meant more like what this command does `start powershell -noexit "something"` (But in invisible mode) – Arty May 17 '19 at 16:34
  • Hello, Im using a VBS file to run something in invisible mode, in first batch I want to execute the vbs to run new batch in invisible mode, but I need to pass a string to the batch wich will be created in invisible mode. @Pimp Juice IT – Arty May 17 '19 at 20:38
  • I need to pass only one argument to powershell from batch, powershell has to execute (but powershell is the one wich needs to be invisible) – Arty May 17 '19 at 22:23
  • @Arty Try something like.... `powershell -windowstyle hidden -command get-childitem -path c:\` where `childitem -path c:\` is a command example. If you put that in your batch script, then you can call the batch script with an argument which is what you build the command to use within the batch.... Just like this sample `powershell -windowstyle hidden -command get-childitem -path c:\` I provided. I wrote about this here: https://superuser.com/questions/1331143/how-to-run-a-powershell-command-silently/1331153#1331153 – Vomit IT - Chunky Mess Style May 17 '19 at 22:28
  • Very nice! @Pimp Juice IT, but I just realized that I need that for cmd too :/ – Arty May 17 '19 at 22:33
  • it is so weird system, but CMD does not let me use ren to rename folder with spaces to other name but still with spaces, for that I use powershell, and then I need to use CMD, because I dont know the ATTRIB syntax for powershell – Arty May 17 '19 at 22:39
  • Well I have done some changes to its, but now... I just need to run batch invisible, because It is all running from HTA, and my exec() function actually everytime calls cmd.. – Arty May 17 '19 at 22:53
  • @Arty Ok, if that's the case and all you really only need now it to run batch invisible, then the above example is what you need as in `C:\folder\path\InvisibeArgTest.vbs "C:\folder\path\script.bat"`?? I'm not sure what changes you made but word-for-word if that's all you need now, then the answer I provided does just that. You only need to call the VBS or converted EXE passing in the full path to the batch file. – Vomit IT - Chunky Mess Style May 17 '19 at 23:40
  • @Arty If that's not what you need, create me a link using https://pastebin.com/ with the batch code and/or whatever code you have that you are using the build the variable which needs to execute the batch file and pass in the argument if per your most recent changes you still need to argument. I think some examples of your logic would help since things are changing and thus the correlated requirements. – Vomit IT - Chunky Mess Style May 17 '19 at 23:42