Heaney Posted June 20, 2011 Share Posted June 20, 2011 (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 offSET APPDATA=N:/data/Start "Test" "N:\Test.jar"I would be very appreciative if someone can convert this into a vbs file! Edited June 20, 2011 by Heaney Link to comment Share on other sites More sharing options...
gunsmokingman Posted June 20, 2011 Share Posted June 20, 2011 Here I try this VBS script, I have added a check to make sure the file exists.Save as JarCheck.vbsDim 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 Link to comment Share on other sites More sharing options...
Heaney Posted June 20, 2011 Author Share Posted June 20, 2011 (edited) Hi. That's great but you missed out mySET 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 usestrAppData=objShell.ExpandEnvironmentStrings("%APPDATA%")And then something, but not the something Edited June 20, 2011 by Heaney Link to comment Share on other sites More sharing options...
gunsmokingman Posted June 20, 2011 Share Posted June 20, 2011 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 myVBS script.@echo offSET 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. Link to comment Share on other sites More sharing options...
allen2 Posted June 20, 2011 Share Posted June 20, 2011 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= Link to comment Share on other sites More sharing options...
Heaney Posted June 20, 2011 Author Share Posted June 20, 2011 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 myVBS script.@echo offSET 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 Link to comment Share on other sites More sharing options...
Heaney Posted June 20, 2011 Author Share Posted June 20, 2011 It's fine though, I just converted the batch to exe Link to comment Share on other sites More sharing options...
Yzöwl Posted June 20, 2011 Share Posted June 20, 2011 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. Link to comment Share on other sites More sharing options...
gunsmokingman Posted June 20, 2011 Share Posted June 20, 2011 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 myVBS script.@echo offSET 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/ worksMaybe 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 Ihave to change the system variable %Appdata% to a fixed path, for my app to work. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now