Jump to content

Recommended Posts

Posted (edited)

Hello.

I know how to write batch files, and have written one to perform a task.

However, I need to convert this into a vbs file, because the system I am running this on does not have permission to use batch files.

Here is the batch file:

@echo off
SET APPDATA=N:/data/
Start "Test" "N:\Test.jar"

I would be very appreciative if someone can convert this into a vbs file! :)

Edited by Heaney

Posted

Here I try this VBS script, I have added a check to make sure the file exists.

Save as JarCheck.vbs


Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
'-> Check To Make Sure File Exists
If Fso.FileExists("N:\Test.jar") Then
Act.Run("Test N:\Test.jar"),1,True
Else
MsgBox "Error Missing File N:\Test.jar",4128,"Error Missing File"
End if

Posted (edited)

Hi. That's great but you missed out my

SET APPDATA=N:/data/

Bit.

That's the important bit.

I need to set it so that it will think %Appdata% is actually in N:\data\

I know how to do that in batch files but not in vbscript :/

I know that you use

strAppData=objShell.ExpandEnvironmentStrings("%APPDATA%")

And then something, but not the something :(

Edited by Heaney
Posted

First of all, from the code you posted APPDATA does nothing other then waste a line.

It is not used at all in the below batch script. So there was no point in adding it to my

VBS script.


@echo off
SET APPDATA=N:/data/
Start "Test" "N:\Test.jar"

If you can not provide full script then do not complain when someone takes the time to do

what you request, when you are the one at fault for providing less then the full script.

Posted

Some app like java app need environment variables to be set before they are launched.

A very dirty way to do it would be something like this:

set wsh=createobject("wscript.shell")
wsh.run ("cmd /c set APPDATA=N:/data/ & Start " & chr(34) & "Test" & chr(34) & "N:\Test.jar" & chr(34),0, true)
set wsh=

Posted

First of all, from the code you posted APPDATA does nothing other then waste a line.

It is not used at all in the below batch script. So there was no point in adding it to my

VBS script.


@echo off
SET APPDATA=N:/data/
Start "Test" "N:\Test.jar"

If you can not provide full script then do not complain when someone takes the time to do

what you request, when you are the one at fault for providing less then the full script.

WRONG. It works.

Fully.

SET APPDATA=N:/data/ 

works

Posted

You should not really be setting a system variable which holds a fixed path hidden to the end user and with no pre-checks, error trapping etc.

Posted

First of all, from the code you posted APPDATA does nothing other then waste a line.

It is not used at all in the below batch script. So there was no point in adding it to my

VBS script.


@echo off
SET APPDATA=N:/data/
Start "Test" "N:\Test.jar"

If you can not provide full script then do not complain when someone takes the time to do

what you request, when you are the one at fault for providing less then the full script.

WRONG. It works.

Fully.

SET APPDATA=N:/data/ 

works

Maybe you should learn to read, I said it was not needed in the code you provided.

There again you are not providing this thread with all details, where does it say I

have to change the system variable %Appdata% to a fixed path, for my app to work.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...