Is there a way to launch two Explorer windows side-by-side (vertically tiled) with a Batch script?
If not, how might I do this with VBS?
I have modified the VBS script above by Hackoo to do exactly what the OP wants...
The comments in the script explain exactly what it will do.
If the two windows don't set into correct position, increase the 'Sleep' time and try again.
If you want a horizontal split, use 'objShell.TileHorizontally'.
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' Launches two Explorer windows side-by-side filling the screen dimensions.
''' Minimizes all current open windows before launch; if this is not done,
''' the current open windows will also be resized along with our two windows.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Calc,AppData,objShell
Calc = "%windir%\system32\calc.exe"
AppData = "%AppData%"
Set objShell = CreateObject("shell.application")
objShell.MinimizeAll
Call Explore(Calc)
WScript.Sleep 800
Call Explore(AppData)
WScript.Sleep 800
objShell.TileVertically
Set objShell = nothing
'*****************************************************
Function Explore(Path)
Dim ws
set ws = CreateObject("wscript.shell")
Explore = ws.run("Explorer /n,/select,"& Path &"")
End Function
'*****************************************************
This might be in the same category as your question. :)
How can a batch file run a program and set the position and size of the window?
Unfortunately it seems that its not possible without any external third part software in batch. Probably easier in VBS - if so the answer should be in the link.
Try this code :
Option Explicit
Dim Calc,AppData
Calc = "%windir%\system32\calc.exe"
AppData = "%AppData%"
Call Explore(Calc)
Call Explore(AppData)
'*****************************************************
Function Explore(Path)
Dim ws
set ws = CreateObject("wscript.shell")
Explore = ws.run("Explorer /n,/select,"& Path &"")
End Function
'*****************************************************
Related
Can anyone help me with this problem, i need to call/execute bat file. below are my codes for bat file and asp classic.
test.bat
echo off
start C:\inetpub\wwwroot\Texting\Notification.lnk
That test.bat will run a shortcut and call the application, that will update received file.
sample.asp this code is for classic asp
<%
dim fs,tfile,loc,locadd,loctime1,nameFile,wshell
locadd = Month(Date)&Day(Date)&Year(Date)
loctime1 = stripNonNumeric(FormatDateTime(Now,3))
nameFile = "\\85new\Accts85new\Texting\Reply\Karing\"
loc = "\\85new\Accts85new\Texting\Reply\Karing\"&locadd&"_"&loctime1&".txt"
set fs= Server.CreateObject("Scripting.FileSystemObject")
set tfile=fs.CreateTextFile(loc)
For Each Item in Request.QueryString
tfile.Write Item &";"& Request.QueryString(Item)&"$&$"
next
tfile.close
set tfile=nothing
set fs=nothing
Function stripNonNumeric(inputString)
Set regEx = New RegExp
regEx.Global = True
regEx.Pattern = "\D"
stripNonNumeric = regEx.Replace(inputString,"")
End Function
set wshell = CreateObject("WScript.Shell")
wshell.Run "cmd.exe /c C:\inetpub\wwwroot\Texting\test1.bat"
set wshell = nothing
%>
that sample.asp will get the value of parameters from querystring.
The code is working, no error received when i hit ENTER on the browser.
Thank you in advance!
Typically this should be done in another way, but assuming you understand the security implications of calling bat file from a web application, you need to try to redirect output to a file to ensure it is executed and what is the output, i.e.
wshell.Run "test1.bat>debug.txt"
CreateObject("WScript.Shell") is executed in a separate process and you will not get any error in the browser, that's why your bat file needs to output its result somewhere.
I would like to silent print a PDF file multiple times. I don't really mind what implementation is used, but due to being in a corporate environment I cannot easily install unsupported software :(.
I am currently using the following VBscript but could switch to any other implementation:
TargetFolder = "<path to folder>"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TargetFolder)
Set colItems = objFolder.Items
For Each objItem In colItems
For i = 1 To 13
objItem.InvokeVerbEx ("Print")
Next
Next
This spools the job 13 times though. Is there a way to do this as a single job?
I also saw a suggestion for printing using adobe reader that looked like this:
AcroRd32.exe /t <file.pdf> <printer_name> <printer_driver> <printer_port>
But I couldn't find any reference material for passing the number of copies as a parameter.
I just found this questions which is essentially the same:
Programatically print multiple copies from command line
It appears that looping through and sending the file multiple times is the only solution without additional software.
I am trying to control Spotify volume from inside a game without switching windows. To do this I did the following:
A. Found nircmd.exe from NirSoft that can control individual program volumes in Windows
B. Wrote a batch to execute the command
C. Wrote this .vbs script to hook into the batch silently:
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & "Spotify App Volume Up.bat" & Chr(34), 0
Set WshShell = Nothing
^
Using this .vbs snippet to accomplish silent run is really popular. This works when I click the .vbs myself. The problem I have is I need a way to execute this from another program. When I try to execute from any hotkey program or something like AutoHotKey it gives me this error:
ActiveX Component cannot create object 'WScript.Shell' Code: 800a01ad
I tried setting security of all involved files to everyone, full control. It did not help. It seems to me that Windows is trying to protect me by preventing scripts from initializing by other programs. Any suggestions? Otherwise does someone know how to execute this silently with another method?
EDIT:
AutoHotKey's run command will do this:
run "mybat.bat",, Hide
However, does anyone know how to get around this behavior with .vbs? I am curious.
I believe all your scripts, vbscript and your batch file can potentially be written natively in Ahk, but here's how I'd launch your vb script.
x:: ; press x
sc := ComObjCreate("ScriptControl")
sc.Language := "VBScript"
script =
(
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & "Spotify App Volume Up.bat" & Chr(34), 0
Set WshShell = Nothing
)
sc.ExecuteStatement(script)
return
Take the following script that I have:
x=msgbox ("Do you want to recycle the Premiere Pro Media Cache?" ,4, "Recycle Premiere Pro Media Cache")
If box =6 Then
CreateObject("wscript.shell").run "C:\Expedited\Scripts\PrMCRecycler1"
End If
My goal is to get this VBS file (which brings up a message box) to run the batch file (the same way it would run when double-clicking it) when the yes button is pressed. I'm not sure what I'm doing wrong above. When I click No, nothing needs to happen, so I didn't specify anything for it.
Basically, since it brings up a yes/no message box, I just need to make the yes button execute the specified batch file. I could really use some assistance in figuring out what's wrong. When I try the code listed above, nothing happens upon choosing yes (besides the dialogue box going away).
Try this example and change the path of your batch file.
Option Explicit
Dim ws,Question,PathProgram
Set ws = CreateObject("wscript.shell")
'change the path of your batch file
PathProgram = "C:\Program Files\Internet Explorer\iexplore.exe"
Question = Msgbox("Do you want to recycle the Premiere Pro Media Cache?",VbYesNO + VbQuestion, "Recycle Premiere Pro Media Cache")
If Question = VbYes Then
ws.run DblQuote(PathProgram)
End If
'***************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'***************************************
Can't seem to nail this one down... Is there a programmatic/batchish way to rename a set of files in the same directory from 1_body.html, 2_body.html, etc to 1.html, 2.html?
I'm just a regular user, so I wont have permissions to do anything too fancy :).
As it always seems to go, after hours of digging I found the answer right after posting this...
rename ?_body.html ?.html
rename ??_body.html ??.html
rename ???_body.html ???.html
Took care of it.
You could also do it using VBScript. Here's an example (based on this script):
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".") ''# Current directory
Set objFolder = objFSO.GetFolder(strFolder)
For Each strFiles In objFolder.Files
If objFSO.GetExtensionName(strFiles) = "html" Then
strComponents = Split(strFiles.Name, "_")
strFiles.Name = strComponents(0) + ".html"
End If
Next
Save the above as something.vbs in the directory it is to run and double click to run it.