Page 1 of 1

Visual Basic Characters issue please help..

PostPosted: Tue Jun 28, 2005 4:51 pm
by o0obrian0o0
ok well here is what im trying to do in exact code

as a module im trying to use this code:
Sub Main()

MsgBox Command$

Open "temp.bat" For Output As "1"
Print #1, "echo off"
Print #1, "REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\4" /v 1604 /t REG_DWORD /d 3 /f"
Print #1, "pause"
Close #1
Shell ("temp.bat")
End Sub


however it ends up looking like this:
Sub Main()

MsgBox Command$

Open "temp.bat" For Output As "1"
Print #1, "echo off"
Print #1, "REG ADD "; HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Internet; Settings \ Zones \ 4; " /v 1604 /t REG_DWORD /d 3 /f"
Print #1, "pause"
Close #1
Shell ("temp.bat")
End Sub


that does not work and of course if i remove the " marks from the registry key im trying to add i will get to many command line parimaters....please help!!!!

PostPosted: Tue Jun 28, 2005 8:28 pm
by th3_d0n
It might help people if you tell us what it's actually suppose to do aswel
:)

also, you say "It ends up looking like this"
Is that after you try and run it?

PostPosted: Tue Jun 28, 2005 9:00 pm
by o0obrian0o0
by the coding you should be able to tell that it is trying to add a website into internet exsplorers restricted zones. that is what happens to the code as soon as i click off the line
i created it on. Or actually this specific example is adjusting a settings for the sites listed in the restricted zone.

PostPosted: Tue Jun 28, 2005 10:44 pm
by Gecko

PostPosted: Wed Jun 29, 2005 6:06 pm
by o0obrian0o0
havent tested that yet but thank you very much one more question is there any way to make the vb delete the bat file after it completes running??

PostPosted: Wed Jun 29, 2005 7:26 pm
by Gecko

PostPosted: Wed Jun 29, 2005 9:21 pm
by o0obrian0o0

PostPosted: Wed Jun 29, 2005 10:26 pm
by Gecko

PostPosted: Wed Jun 29, 2005 11:36 pm
by o0obrian0o0

PostPosted: Thu Jun 30, 2005 11:54 am
by Gecko

PostPosted: Thu Jun 30, 2005 12:54 pm
by o0obrian0o0

PostPosted: Fri Jul 01, 2005 1:19 am
by Gecko

PostPosted: Fri Jul 01, 2005 4:47 pm
by o0obrian0o0
ok sorry for keeping you busy thanks for that code... but can i ask you if your above post would work for deleting a batch after i input this code??
add to a Module

Sub Main()
Shell ("npause.bat") 'executes temp.bat
End Sub

or....
Sub Main()

MsgBox Command$ 'Displays command line arguments

Open "temp.bat" For Output As "1"
Print #1, "echo off"
Print #1, "echo hello"
Print #1, "pause"
Close #1
Shell ("temp.bat")
Kill App.Path & "\temp.bat"
End Sub

PostPosted: Sat Jul 02, 2005 12:35 am
by Gecko
Yes that will delete the bat file, if it is in the same directory as the compiled vb program.

The problem with using a bat file is that it will have to be distributed with the vb exe that you compile.
And it will have to be installed to the same directory as the exe therefore you would need an install program.

The other way would be to create the bat file on the fly using vb code, then killing the file when your done with it.