I am trying to open a .dita file (which I was hoping would launch my editor) through VBScript.I keep getting a Run Time error on this line of code:
CreateObject("WScript.Shell").Run "testfile.dita"
The every helpful error message is just "Error". I'm assuming it's the file type because it works with .exe and .txt files. Could anyone suggest how I'd fix this or offer an alternative please?
this should work
CreateObject("WScript.Shell").Run "cmd /c start testfile.dita"
Related
I am trying to open a .chm file from a batch file.
The batch file has only this text in it :
echo off
start "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"
If I run the batch file, the commandline opens but nothing further happens.
If I copy paste S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm in start menu/run then it does works.
If I make a shortcut with target "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm" then it also works.
So the command works everywhere, except from a batch file.
What am I doing wrong here ?
It might also be important to know that when I start it from the shortcut, or start menu/runI always get a dialog
We can't verify who created this file. Are you sure you want to open this file ?
I am using Windows 7
EDIT
My problem is not the dialog, my problem is that nothing happens when I open the chm file from a batch file
The Start command is probably seeing your doublequoted string as a title, enter Start /? at the command prompt for its usage information.
Try adding an empty title first:
#Echo Off
Start "" "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"
I have created a VBScript file, and I want it to open itself again. I currently have
CreateObject("WScript.Shell").Run("W:\\Downloads\\FileName.vbs")
But I want it to open itself without a specific path, because I don't know where the file will be. Is that possible?
As #JosefZ pointed out: use the ScriptFullName property to get the full path of the script.
CreateObject("WScript.Shell").Run WScript.ScriptFullName
Try this one
CreateObject ("WScript.Shell").Run(".\filename.vbs")
It will open the file which is in the same folder in which the VBS file is , no need to specify the rest of the path.
You can add a MsgBox "text" so that the program does not terminates or else only one program will run oneat a time.
I am trying to make a scheduled batch file to run with the volume shadow copy service to copy the outlook.pst file from microsoft outlook.
The commands work properly when i enter them in the command panel but when i setup the same code in a batch file it gives me an invalid number of parameters error in during the second line.
You have to use administrator access on cmd and the batch file for it to even work and i am doing that but i have no clue as to why i get an error only in the batch version but not in cmd?
I found this link helpful.
Its where i found the batch file which simplifies the process incase anyone is wondering.
Heres the code :
CALL MountLatestShadowCopy "C:\MyShadow\"
xcopy /y "C:\MyShadow\Users\%USERNAME%\Documents\Outlookove datoteke\*.pst" "\\hyp\backup"
RMDIR "C:\MyShadow"
pause
Anyone have any ideas as to the cause of my problems? Its supposed to simply copy the .pst file to a server for backup which i will run on a regular schedule.
Outlook is usually the first thing people open when they turn on their computers so i have to use volume shadow copy otherwise getting a copy might be hard on certain computers.
Thanks for the help in advance!
i have made a batch file in windows 7 OS. When i double click on that batch file it opens in notepad and it is not executing code of my batch file. What should i do now to run or execute batch file? Please help me. It is so much serious for me .
OK there are many things that could be wrong and many ways to fix it but i think the quickest way to fix it would be to rename you file to a .cmd instead of a .bat (they are just the same.)
find that reg key and delete value data "notepad.exe"
HKEY_CURRENT_USER \Software \Microsoft \Windows \CurrentVersion \ Explorer \FileExts \.bat \
it will work.
I am writing a script to move files between directories. I copied and edited this script from another post:
MOVE C:\Users\evan\Downloads\*.mp3 C:\Users\evan\Music
and I run it from the CLI using
cscript test.vbs
I would expect it to work, but I get this message:
C:\Users\evan\test.vbs<1,8> Microsoft VBScript compiliation error: Expaected statement
Can someone please explain what this error message means or point out my mistake that causes the error message? Sorry for being such a noob.
That looks like a batch file, but you are trying to invoke it as a VBScript. Rename your file to .bat and invoke it directly.