Hi looking for a bit of help, tried a few things but cant get it to
work, i am trying to run the following DOS command line from a VBS
script.

printmig -b "\\servername\file.cab" \\server1

Tried various ways but no luck can anyone help ?

Thanks

Re: Command line in vbs script by ThatsIT

ThatsIT
Wed Sep 05 04:29:46 PDT 2007


"systemtek" <duncan@systemtek.co.uk> wrote in message
news:1188987737.291381.204490@g4g2000hsf.googlegroups.com...
> Hi looking for a bit of help, tried a few things but cant get it to
> work, i am trying to run the following DOS command line from a VBS
> script.
>
> printmig -b "\\servername\file.cab" \\server1
>
> Tried various ways but no luck can anyone help ?
>
> Thanks
>

set objShell = CreateObject("WScript.Shell")
objShell.run "printmig -b ""\\servername\file.cab"" \\server1"


Re: Command line in vbs script by systemtek

systemtek
Wed Sep 05 05:11:38 PDT 2007

On 5 Sep, 12:29, "ThatsIT.net.au" <me@thatsit> wrote:
> "systemtek" <dun...@systemtek.co.uk> wrote in message
>
> news:1188987737.291381.204490@g4g2000hsf.googlegroups.com...
>
> > Hi looking for a bit of help, tried a few things but cant get it to
> > work, i am trying to run the following DOS command line from a VBS
> > script.
>
> > printmig -b "\\servername\file.cab" \\server1
>
> > Tried various ways but no luck can anyone help ?
>
> > Thanks
>
> set objShell = CreateObject("WScript.Shell")
> objShell.run "printmig -b ""\\servername\file.cab"" \\server1"

Thanks, This seems to work but fail's at the end, if i look in the
error log its trying to make this 'Backup".ca' and it should be
'Backup.cab' in the log file looking at a previous working attempt.

I should have said above you dont put the file extension of the file
in for it to work its just :

set objShell = CreateObject("WScript.Shell")
objShell.run "printmig -b ""\\servername\Backup"" \\server1"

And this should create a file called Backup.cab at the end of it
automatic, but it is not.

If i run this as a dos command line it works fine.

Any ideas ?



Re: Command line in vbs script by ThatsIT

ThatsIT
Wed Sep 05 05:26:10 PDT 2007


"systemtek" <duncan@systemtek.co.uk> wrote in message
news:1188994298.585482.44400@19g2000hsx.googlegroups.com...
> On 5 Sep, 12:29, "ThatsIT.net.au" <me@thatsit> wrote:
>> "systemtek" <dun...@systemtek.co.uk> wrote in message
>>
>> news:1188987737.291381.204490@g4g2000hsf.googlegroups.com...
>>
>> > Hi looking for a bit of help, tried a few things but cant get it to
>> > work, i am trying to run the following DOS command line from a VBS
>> > script.
>>
>> > printmig -b "\\servername\file.cab" \\server1
>>
>> > Tried various ways but no luck can anyone help ?
>>
>> > Thanks
>>
>> set objShell = CreateObject("WScript.Shell")
>> objShell.run "printmig -b ""\\servername\file.cab"" \\server1"
>
> Thanks, This seems to work but fail's at the end, if i look in the
> error log its trying to make this 'Backup".ca' and it should be
> 'Backup.cab' in the log file looking at a previous working attempt.
>
> I should have said above you dont put the file extension of the file
> in for it to work its just :
>
> set objShell = CreateObject("WScript.Shell")
> objShell.run "printmig -b ""\\servername\Backup"" \\server1"
>
> And this should create a file called Backup.cab at the end of it
> automatic, but it is not.
>
> If i run this as a dos command line it works fine.
>
> Any ideas ?
>
>

the script should just execute your command line, from there their should be
no difference. But if there is I am at a loss to explain why.
you could try

errorCode = objShell.run( "printmig -b ""\\servername\Backup"" \\server1"
,1,true)

WSCript.echo errorCode

the 1 will make it ruin in a window, replace with 0 to run without, the true
will make the script wait till command ends and will return a error code


Re: Command line in vbs script by ThatsIT

ThatsIT
Wed Sep 05 05:27:50 PDT 2007

Also try

objShell.exec

"systemtek" <duncan@systemtek.co.uk> wrote in message
news:1188994298.585482.44400@19g2000hsx.googlegroups.com...
> On 5 Sep, 12:29, "ThatsIT.net.au" <me@thatsit> wrote:
>> "systemtek" <dun...@systemtek.co.uk> wrote in message
>>
>> news:1188987737.291381.204490@g4g2000hsf.googlegroups.com...
>>
>> > Hi looking for a bit of help, tried a few things but cant get it to
>> > work, i am trying to run the following DOS command line from a VBS
>> > script.
>>
>> > printmig -b "\\servername\file.cab" \\server1
>>
>> > Tried various ways but no luck can anyone help ?
>>
>> > Thanks
>>
>> set objShell = CreateObject("WScript.Shell")
>> objShell.run "printmig -b ""\\servername\file.cab"" \\server1"
>
> Thanks, This seems to work but fail's at the end, if i look in the
> error log its trying to make this 'Backup".ca' and it should be
> 'Backup.cab' in the log file looking at a previous working attempt.
>
> I should have said above you dont put the file extension of the file
> in for it to work its just :
>
> set objShell = CreateObject("WScript.Shell")
> objShell.run "printmig -b ""\\servername\Backup"" \\server1"
>
> And this should create a file called Backup.cab at the end of it
> automatic, but it is not.
>
> If i run this as a dos command line it works fine.
>
> Any ideas ?
>
>


Re: Command line in vbs script by systemtek

systemtek
Wed Sep 05 05:43:30 PDT 2007

On 5 Sep, 13:27, "ThatsIT.net.au" <me@thatsit> wrote:
> Also try
>
> objShell.exec
>
> "systemtek" <dun...@systemtek.co.uk> wrote in message
>
> news:1188994298.585482.44400@19g2000hsx.googlegroups.com...
>
> > On 5 Sep, 12:29, "ThatsIT.net.au" <me@thatsit> wrote:
> >> "systemtek" <dun...@systemtek.co.uk> wrote in message
>
> >>news:1188987737.291381.204490@g4g2000hsf.googlegroups.com...
>
> >> > Hi looking for a bit of help, tried a few things but cant get it to
> >> > work, i am trying to run the following DOS command line from a VBS
> >> > script.
>
> >> > printmig -b "\\servername\file.cab" \\server1
>
> >> > Tried various ways but no luck can anyone help ?
>
> >> > Thanks
>
> >> set objShell = CreateObject("WScript.Shell")
> >> objShell.run "printmig -b ""\\servername\file.cab"" \\server1"
>
> > Thanks, This seems to work but fail's at the end, if i look in the
> > error log its trying to make this 'Backup".ca' and it should be
> > 'Backup.cab' in the log file looking at a previous working attempt.
>
> > I should have said above you dont put the file extension of the file
> > in for it to work its just :
>
> > set objShell = CreateObject("WScript.Shell")
> > objShell.run "printmig -b ""\\servername\Backup"" \\server1"
>
> > And this should create a file called Backup.cab at the end of it
> > automatic, but it is not.
>
> > If i run this as a dos command line it works fine.
>
> > Any ideas ?

Tried this just get error box with " 0 " in it. Will have a play with
it see if i can find out why.


Re: Command line in vbs script by Richard

Richard
Wed Sep 05 06:08:52 PDT 2007


"systemtek" <duncan@systemtek.co.uk> wrote in message
news:1188996210.355831.250430@22g2000hsm.googlegroups.com...
> On 5 Sep, 13:27, "ThatsIT.net.au" <me@thatsit> wrote:
>> Also try
>>
>> objShell.exec
>>
>> "systemtek" <dun...@systemtek.co.uk> wrote in message
>>
>> news:1188994298.585482.44400@19g2000hsx.googlegroups.com...
>>
>> > On 5 Sep, 12:29, "ThatsIT.net.au" <me@thatsit> wrote:
>> >> "systemtek" <dun...@systemtek.co.uk> wrote in message
>>
>> >>news:1188987737.291381.204490@g4g2000hsf.googlegroups.com...
>>
>> >> > Hi looking for a bit of help, tried a few things but cant get it to
>> >> > work, i am trying to run the following DOS command line from a VBS
>> >> > script.
>>
>> >> > printmig -b "\\servername\file.cab" \\server1
>>
>> >> > Tried various ways but no luck can anyone help ?
>>
>> >> > Thanks
>>
>> >> set objShell = CreateObject("WScript.Shell")
>> >> objShell.run "printmig -b ""\\servername\file.cab"" \\server1"
>>
>> > Thanks, This seems to work but fail's at the end, if i look in the
>> > error log its trying to make this 'Backup".ca' and it should be
>> > 'Backup.cab' in the log file looking at a previous working attempt.
>>
>> > I should have said above you dont put the file extension of the file
>> > in for it to work its just :
>>
>> > set objShell = CreateObject("WScript.Shell")
>> > objShell.run "printmig -b ""\\servername\Backup"" \\server1"
>>
>> > And this should create a file called Backup.cab at the end of it
>> > automatic, but it is not.
>>
>> > If i run this as a dos command line it works fine.
>>
>> > Any ideas ?
>
> Tried this just get error box with " 0 " in it. Will have a play with
> it see if i can find out why.
>

To help troubleshoot, assign the dos command to a variable. Then you can
echo it to the command line and see if it is correct. It should look exactly
like the command you enter manually. For example:
==========
set objShell = CreateObject("WScript.Shell")
strCmd = "printmig -b ""\\servername\Backup"" \\server1"
Wscript.Echo strCmd
strError = objShell.Run(strCmd, 1, True)
Wscript.Echo "Return code = " & strError
==========
I would expect this to echo:
===========
printmig -b "\\Servername\Backup" \\server1
Return code = 0
==========
The return code will be 0 if no error was returned by printmig. If printmig
spawned another process that generated an error, then you won't get an error
code from the spawned process.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--



Re: Command line in vbs script by Harvey

Harvey
Thu Sep 06 08:00:46 PDT 2007

You need to do a little research before asking.

http://www.google.com/search?hl=en&q=vbscript+dos+command

Here's a reprint of a reply I made just a couple of days ago.

--------------------------------------------------------------

It's very easy to run external commands from with in a
vbScript. Here's the basics for running a DOS command. . .

By specifically running a copy of CMD.EXE (%COMSPEC% /c)
you can then redirect any output from the command to a
log file. This file can then be parsed to verify success.
In the case of the "NET USER" command, you can
look for the "The command completed successfully"
statement.


Set oWS = WScript.CreateObject("WScript.Shell")

sLog = "C:\StandOut.txt"

sDOS_CMD = "dir /b /s C:\*.tmp"

oWS.Run "%comspec% /c " & sDOS_CMD & " > " & sLog, 1, True

oWS.Run "notepad.exe " & sLog


Re: Command line in vbs script by systemtek

systemtek
Mon Sep 10 03:26:32 PDT 2007

On 6 Sep, 16:00, "Harvey Colwell" <HarveyColw...@effingham.net> wrote:
> You need to do a little research before asking.
>
> http://www.google.com/search?hl=en&q=vbscript+dos+command
>
> Here's a reprint of a reply I made just a couple of days ago.
>
> --------------------------------------------------------------
>
> It's very easy to run external commands from with in a
> vbScript. Here's the basics for running a DOS command. . .
>
> By specifically running a copy of CMD.EXE (%COMSPEC% /c)
> you can then redirect any output from the command to a
> log file. This file can then be parsed to verify success.
> In the case of the "NET USER" command, you can
> look for the "The command completed successfully"
> statement.
>
> Set oWS = WScript.CreateObject("WScript.Shell")
>
> sLog = "C:\StandOut.txt"
>
> sDOS_CMD = "dir /b /s C:\*.tmp"
>
> oWS.Run "%comspec% /c " & sDOS_CMD & " > " & sLog, 1, True
>
> oWS.Run "notepad.exe " & sLog

Managed to get it going now, thanks for the replys.