Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 How to run a .bat file using vb 6.0

Author  Topic 

srinivas.alwala
Starting Member

30 Posts

Posted - 2007-11-30 : 02:33:54

Hi,

I have created a batch file.

The purpose of batch file is to execute a form.

If you have code in vb to execute batch file.

Kindly, let me know.

Regards,

Srinivas Alwala

tm
Posting Yak Master

160 Posts

Posted - 2007-11-30 : 10:46:48
Did this long long time ago and I do believe you should use Shell function in VB 6.0.

http://msdn2.microsoft.com/en-us/library/xe736fyk(VS.71).aspx
Go to Top of Page

srinivas.alwala
Starting Member

30 Posts

Posted - 2007-12-18 : 07:39:03
Hi,

I have tried the Shell function but the execution fails.

Kindly, let me know the code.


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-18 : 08:24:58
WHY do the execution fail? Do you get ANY errors at all?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

tm
Posting Yak Master

160 Posts

Posted - 2007-12-18 : 14:19:52
As Peso mentioned do you get any errors.

You can try this to see shell work ..
(I tested and it works. Since I did not have VB 6 installed I used Excel VBA which is the same.)

1. Create a function in your VB application ..

Public Function ShellTest() As Double
Dim ProcID As Double
ProcID = Shell("C:\Test.bat", vbNormalFocus)
End Function

2. Create a batch file on your C drive root and only have "pause" in the batch file (remove the double quotes. pause only). Pause will wait for key press to close the command window so you know it has started.

3. Run application and call ShellTest function to see command window.
Go to Top of Page

srinivas.alwala
Starting Member

30 Posts

Posted - 2007-12-21 : 04:28:34
Hi,

The batch file which is in production server, I need to execute this batch file from development server where vb code exists.

Visual Basic was not installed in production server and sql server 2005 exists.

In development server sql server 2000 exists.

Kindly, let me know, how to execute this batch file remotely.

Regards,

Srinivas Alwala
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-21 : 04:40:10
I don't remember right now if Shell function supports UNC path names.
Even if it does, the bat file is executed locally.


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -