Batch file help

Discussion in 'Computing, Science, and Technology' started by Retro349, Aug 5, 2009.

  1. Retro349

    Retro349 New Member

    Joined:
    Jan 18, 2009
    Messages:
    355
    Likes Received:
    0
    Device:
    iPhone 4 (Black)
    I'm trying to make a batch file that will run a VNC tunnel automatically. I got bored, so I started to polish it up and add features so maybe I could release it here for all to enjoy. I'm almost done, but I have one problem. I had it promt the user for the iTunes install drive, and move iTunesMobileDevice.dll into the prober folder for tunneling to work. When I do that, it doesn't move it, It just goes back to the same screen prompting for the drive letter. I'm new at batch, so it's probably something stupid, but can someone tell me what i'm doing wrong?

    Code:
    @ECHO OFF
    ECHO.Running Checks...
    :startchecks
    IF NOT EXIST iTunesmobiledevice.dll GOTO incorrectfiles
    IF NOT EXIST vncviewer.exe GOTO incorrectfiles
    IF NOT EXIST iTunnel.exe GOTO incorrectfiles
    ECHO.Make sure your device is plugged in via usb, and that veency is installed and running.
    PAUSE
    ECHO.Starting client...
    START vncviewer.exe 127.0.0.1
    CLS
    ECHO.Starting Tunnel...
    CLS
    ECHO.Now press "Accept" on your iPhone / iPod Touch.
    "%~dp0iTunnel.exe" 5900 5900
    :GOTO end
    :incorrectfiles
    CLS
    ECHO.One or more files is missing!
    ECHO.Correct Filesystem:
    ECHO.-------------------------------------------
    ECHO.%~dp0
    ECHO.	TunnelVision.bat
    IF NOT EXIST vncviewer.exe ECHO.	vncviewer.exe - MISSING!
    IF EXIST vncviewer.exe ECHO.	vncviewer.exe
    IF NOT EXIST iTunnel.exe ECHO.	iTunnel.exe - MISSISNG!
    IF EXIST iTunnel.exe ECHO.	iTunnel.exe
    IF EXIST iTunesMobileDevice.dll ECHO.	iTunesMobileDevice.dll
    IF NOT EXIST iTunesmobiledevice.dll ECHO.	iTunesmobiledevice.dll - MISSING!
    ECHO.-------------------------------------------
    IF NOT EXIST iTunesMobileDevice.dll GOTO findiTunesmobiledevice.dll
    ECHO.Press Enter to download missing files:
    PAUSE
    :dliTunnel.exe
    IF NOT EXIST iTunnel.exe explorer http://www.gazup.com/a47SG-itunnel.exe-download-mirrors
    IF EXIST iTunnel.exe GOTO dlvncviewer.exe
    CLS
    ECHO.Place this file in %~dp0
    PAUSE
    IF NOT EXIST iTunnel.exe goto dliTunnel.exe
    IF EXIST vncviewer.exe goto startchecks
    :dlvncviewer.exe
    IF NOT EXIST vncviewer.exe explorer http://www.gazup.com/ukurG-vncviewer.exe-download-mirrors
    CLS
    ECHO.Place this file in %~dp0
    PAUSE
    IF NOT EXIST vncviewer.exe GOTO dlvncviewer.exe
    IF NOT EXIST iTunnel.exe GOTO dliTunnel.exe
    GOTO startchecks
    :findiTunesmobiledevice.dll
    ECHO.TunnelVision can automatically find and move iTunesmobiledevice.dll.
    ECHO.What is the letter of the drive that iTunes is installed on? (Most likely C)
    set /p iTunesinstalldrive=
    ECHO.Are you sure %iTunesinstalldrive%:\ is the right drive?
    PAUSE
    copy "%iTunesinstalldrive%:\Program Files\Common Files\Apple\Mobile Device Support\bin\iTunesMobileDevice.dll" %~dp0
    GOTO startchecks
    :end
  2. liammk

    liammk New Member

    Joined:
    Nov 13, 2008
    Messages:
    373
    Likes Received:
    0
    see were it says GOTO startchecks at the end? that is instructing the script to go to :startchecks so its telling the script to basicaly do everything under :startchecks again. heres what the script should look like:

    ECHO.Running Checks...
    :startchecks
    IF NOT EXIST iTunesmobiledevice.dll GOTO incorrectfiles
    IF NOT EXIST vncviewer.exe GOTO incorrectfiles
    IF NOT EXIST iTunnel.exe GOTO incorrectfiles
    ...
    :incorrectfiles
    CLS
    ECHO.One or more files is missing!
    ECHO.Correct Filesystem:
    ECHO.-------------------------------------------
    ECHO.%~dp0
    ECHO. TunnelVision.bat
    IF NOT EXIST vncviewer.exe ECHO. vncviewer.exe - MISSING!
    IF EXIST vncviewer.exe ECHO. vncviewer.exe
    IF NOT EXIST iTunnel.exe ECHO. iTunnel.exe - MISSISNG!
    IF EXIST iTunnel.exe ECHO. iTunnel.exe
    IF EXIST iTunesMobileDevice.dll ECHO. iTunesMobileDevice.dll
    IF NOT EXIST iTunesmobiledevice.dll ECHO. iTunesmobiledevice.dll - MISSING!
    ECHO.-------------------------------------------
    IF NOT EXIST iTunesMobileDevice.dll GOTO findiTunesmobiledevice.dll
    ...
    :findiTunesmobiledevice.dll
    ECHO.TunnelVision can automatically find and move iTunesmobiledevice.dll.
    ECHO.What is the letter of the drive that iTunes is installed on? (Most likely C)
    set /p iTunesinstalldrive=
    ECHO.Are you sure %iTunesinstalldrive%:\ is the right drive?
    PAUSE
    copy "%iTunesinstalldrive%:\Program Files\Common Files\Apple\Mobile Device Support\bin\iTunesMobileDevice.dll" %~dp0



    IF NOT EXIST iTunesmobiledevice.dll GOTO incorrectfiles
    IF NOT EXIST vncviewer.exe GOTO incorrectfiles
    IF NOT EXIST iTunnel.exe GOTO incorrectfiles
    ...

    CLS
    ECHO.One or more files is missing!
    ECHO.Correct Filesystem:
    ECHO.-------------------------------------------
    ECHO.%~dp0
    ECHO. TunnelVision.bat
    IF NOT EXIST vncviewer.exe ECHO. vncviewer.exe - MISSING!
    IF EXIST vncviewer.exe ECHO. vncviewer.exe
    IF NOT EXIST iTunnel.exe ECHO. iTunnel.exe - MISSISNG!
    IF EXIST iTunnel.exe ECHO. iTunnel.exe
    IF EXIST iTunesMobileDevice.dll ECHO. iTunesMobileDevice.dll
    IF NOT EXIST iTunesmobiledevice.dll ECHO. iTunesmobiledevice.dll - MISSING!
    ECHO.-------------------------------------------
    IF NOT EXIST iTunesMobileDevice.dll GOTO findiTunesmobiledevice.dll
    ...
    pause
  3. Retro349

    Retro349 New Member

    Joined:
    Jan 18, 2009
    Messages:
    355
    Likes Received:
    0
    Device:
    iPhone 4 (Black)
    I edited the post to include the entire code.

    I still don't understand why the copying isn't working... (line 55)

    If iTunesmobileDevice.dll was successfully copied then it would go right through :startchecks without a problem and start the script, right?

    EDIT: And yes, I understand how GOTO works.
    EDIT 2: Oh, I see what you mean, after starting the tunnel it would go through :incorrectfiles. But iTunesMobiledevice.dll still isn't copying.
  4. picklejw

    picklejw Member

    Joined:
    Oct 20, 2008
    Messages:
    875
    Likes Received:
    0
    Device:
    iPad
    i dont have a PC i have a mac and im not to experianced in batch files but have you tryed a simple command first to troubble shoot? like just itunnel into it and put a simple file in there and see if it works do it little parts at a time before you do all the options and checks crap, that way you can hopfully more or less pin-point the problem, thats what i do when i have a problem, good luck!!!

Share This Page