Running batch and vbs ERROR

November 5, 2010 at 21:42:57
Specs: Windows XP, 2 GB
Hi,

This is kind of a weird problem...
I plug in my flash drive, run a batch file, that runs a .vbs file (which is on the computer), that then runs a batch file, but when i unplug the flash drive, the .vbs script gives an error?? something of the sort "Please check if the filename is correct, cannot find \filename". I have checked everything, and it's all in order (meaning the filename is set correct, as well as the location!),

Thanks in advance


See More: Running batch and vbs ERROR

Report •


#1
November 6, 2010 at 06:38:00
when i unplug the flash drive
If your script is trying to use the flash drive after it's unplugged, it won't work, obviously.

How To Ask Questions The Smart Way


Report •

#2
November 6, 2010 at 10:21:01
Hi

Well you see, here's an example so can understand what I mean.
1.bat is in F:\ <- my flash drive, but all it does is start the 1.vbs script so like, wscript "C:\blabla\myuser\documents\1.vbs"
so you see, then I unplug the flash drive, and I don't really see a reason on why I get an error... The flash drive has initiated the file on my computer, so why does it need to stay plugged in? If I unplug it then it just gives me the error mentioned above

Thanks


Report •

#3
November 6, 2010 at 14:41:27
I don't really see a reason on why I get an error
Funny you should mention that. Since you didn't include your scripts, I can't see the problem, either.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
November 6, 2010 at 15:56:19
Hi,

Okay here are the scripts ->
batch 1 (the one that is on the flashdrive and runs the program on the computer)
-------------------------------------------------------------------------------------------------------------------
wscript "C:\Users\sde\Desktop\ttp2.vbs"
-------------------------------------------------------------------------------------------------------------------
ttp2.vbs ->

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\Users\sde\Desktop\zrun.bat" & Chr(34), 0
Set WshShell = Nothing

-------------------------------------------------------------------------------------------------------------------
zrun.bat ->

@echo off
:start
choice /T 30 /c:123456789 %1 /D 1
goto 1
goto start
:1
wscript "C:\Users\sde\Desktop\ttp.vbs"
echo ####2
choice /T 20 /c:123456789 %1 /D 2
goto 2
goto start
:2
wscript "C:\Users\sde\Desktop\ttp.vbs"
-------------------------------------------------------------------------------------------------------------------
ttp.vbs ->

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\Users\sde\Desktop\rz.bat" & Chr(34), 0
Set WshShell = Nothing
-------------------------------------------------------------------------------------------------------------------
rz.bat ->

@echo off
setLocal EnableDelayedExpansion


> #.ftp echo o ftpsite
>> #.ftp echo username
>> #.ftp echo password
>> #.ftp echo cd /docs
>> #.ftp echo prompt
>> #.ftp echo mput "C:\Users\sde\Documents"
>> #.ftp echo bye

ftp -s:#.ftp

Thanks


Report •

#5
November 6, 2010 at 16:10:06
Batch 1, line 1: Add the following line:
C:

How To Ask Questions The Smart Way


Report •

#6
November 7, 2010 at 18:19:29
Thank you, that solved my problem!! :)

Report •

#7
December 22, 2010 at 22:09:42
Hi,
Razor you were really quick about helping me last time, so I would like to ask you another question, on this same program. I added the line in, and now it runs it perfectly even after the flash is removed, however it runs it 100000(theoretically) times instead of just 1 time.

@echo off
:start
choice /T 3600 /c:123456789 %1 /D 1
goto 1
:1
wscript "C:\whatever\some.vbs"
goto start
:end
------------------------------------
This is the script that it runs, and from the coding it should rerun it's self every 1 hour. Instead it runs "lots of those" infinite all at the same time.

Any ideas?

Thanks!


Report •

#8
December 22, 2010 at 22:26:56
Does choice exist?
Can your script find choice?

How To Ask Questions The Smart Way


Report •

#9
December 23, 2010 at 00:28:47
Since windows xp doesn't "come with choice" i put one in the folder where the batch file is being ran.
When I run the batch file by hand so I can see what's going on, it recognizes the choice command and runs within the set seconds.

Thanks


Report •

#10
December 23, 2010 at 05:25:37
Can your script find choice once you change the active drive to C:?

How To Ask Questions The Smart Way


Report •

#11
December 23, 2010 at 13:00:54
Yes,
The choice.exe and the some.vbs and all the other .bat files and things are in the C: drive under the same folder.


Report •

#12
December 23, 2010 at 14:23:15
Then choice is doing something strang. Maybe it doesn't like the number, which is probable if choice is a 16-bit program.

Maybe an easier method would be to use VBS' WScript.Sleep

'Wait 1 hour
WScript.Sleep 60 * 60 * 100

How To Ask Questions The Smart Way


Report •

#13
December 23, 2010 at 15:57:01
Can you be more specific on how I would apply that. I'm still in the beginning stages of scripting.

will it just look like this or?

WScript.Sleep 60 * 60 * 100
wscript "C:\whatever\some.vbs"
loop

-------------


Report •

#14
December 23, 2010 at 16:16:18
It's a VBScript.
echo WScript.Sleep 60 * 60 * 100 > sleep.vbs
:loop
sleep.vbs
"C:\whatever\some.vbs"
goto loop

How To Ask Questions The Smart Way


Report •

#15
January 1, 2011 at 17:54:43
Sorry I did not respond for a long time (I was on vacation without a laptop...)
So, I just got back yesterday and tried to run the script as you have given it to me, however I get an error.

-------------------------
script: location
Line: 1
Char: 20
Error: Expected end of statement
Code: 900A0401
Source: vbscript compilation error
--------------------------
any ideas?


Report •

#16
January 4, 2011 at 16:43:54
My mistake! It works, I just saved it as .vbs instead of .bat...

Report •


Ask Question