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.
Related
I want to call a batch file in my post build step in Visual Studio. Locally the batch file exists, just the command
call "$(SolutionDir)PostBuildSen.bat" "$(TargetDir)" "$(TargetName)"
correctly calls and executes the batch file.
However when I want to check if the batch file exists first (since others will use the same Post Build Event), I get the error
:VCEnd" exited with code 255.
The command is
if exists "$(SolutionDir)PostBuildSen.bat" call "$(SolutionDir)PostBuildSen.bat" "$(TargetDir)" "$(TargetName)"
The Diagnostic output tells me
2> Done executing task "Exec" -- FAILED.
How do you handle this?
The Solution Directory contains a folder with an underscore, i.e. \Dev_Main\ and I have read that for the batch file that is to be called at least that doesn't work. However I am not sure if that is the issue with folders as well and how to cope with it. Also, since the call command works, I am not sure this is the problem.
Furthermore, if I replace the call with cmd /C, the exit code is 1 and the (minmal) output tells me
1>The filename, directory name, or volume label syntax is incorrect.
Also, I will add this as a custom command to a CMakeLists file later on, so the solution needs to work with that.
Thanks to Hans Passant's comment, I solved the problem. The query for the file needs to be if exist rather than if exists.
I have wrapped a simple perl command in a simple windows batch file and executed the same from cmd prompt which worked as expected.
But if I trigger the same batch file from my message flow in IBM Integration Bus, it is unable to recognize the 'perl' command.
Provided the environment variables are set properly and the batch file is working fine from command prompt.
Can anyone please help me on this to identify the issue and resolve the same?
Thanks for the reply.
Actually the error was related to the path from where the batch is calling the perl command.
IIB was always executing it from it's runtime path and that's why it could not recognize the perl command.
The clue is to execute the batch from the path where the perl.exe is present. By following the same the issue got resolved.
I called exe file from Vb6.
Shell "D:\Sample.exe RpNo, PrtVw, glngbr".
We are getting error exe stopped working
I meant to post this as a comment but don't have enough rep to do that.
First of all Shell "D:\Sample.exe RpNo, PrtVw, glngbr" I think the only part of the name of the program you are trying to open is only "D:\Sample.exe" and the rest without the "" quotes so you can try Shell "D:\Sample.exe", RpNo, PrtVw, glngbr
Secondly try opening the program you want to open with the shell statement and see if you get the same error because getting that error should have nothing to do with the program you used to open it the error would be coming from the program "Sample.exe" also what is RpNo, PrtVw, glngbr I've never seen that before, and tried that myself and it didn't work at all, try these out and I hope this helps.
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 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"