Discussion:
NET.EXE and the SHELL command.
(too old to reply)
Dankert
2005-12-02 08:50:08 UTC
Permalink
Hi,

I have a problem hopefully someone could help with.

When I run "NET USE Z: \\Server\Share" from the commandline and then run a
PB 3.5 program under Windows XP like:

OPEN "Z:\Test.txt" FOR OUTPUT AS #1
PRINT #1,"Hello"
CLOSE #1

everything works as expected, but if I instead run the NET command, using
the same syntax as above, from a SHELL statement like

SHELL "NET USE Z: \\Server\Share"
OPEN "Z:\Test.txt".......

the OPEN statement causes BASIC error 76.

When I use "Windows Explorer" to see if the drive has been mapped it
hasn't.(If SHELLing)
Why cant't I map the network drive from a SHELL statement?

Thanks for your time!
Ian Spencer
2005-12-02 11:55:56 UTC
Permalink
Post by Dankert
Hi,
I have a problem hopefully someone could help with.
When I run "NET USE Z: \\Server\Share" from the commandline and then run
OPEN "Z:\Test.txt" FOR OUTPUT AS #1
PRINT #1,"Hello"
CLOSE #1
everything works as expected, but if I instead run the NET command, using
the same syntax as above, from a SHELL statement like
SHELL "NET USE Z: \\Server\Share"
OPEN "Z:\Test.txt".......
the OPEN statement causes BASIC error 76.
When I use "Windows Explorer" to see if the drive has been mapped it
hasn't.(If SHELLing)
Why cant't I map the network drive from a SHELL statement?
Thanks for your time!
I have used the shell in a similar way many times with PB3.5 and never had a
problem, for example :-

shell "net use q:\myserve-serv100\dir1 /persistent:no"
shell "q:\common.bat
shell "net use q: /delete

This works for me in both PB3.5 and PBCC4.01 compiled on my Pentium 3 and
Pentium 4 with XP Pro. The resulting exe has been used with both XP and
Windows NT 4 systems.

Ian
Peter Manders
2005-12-02 13:02:54 UTC
Permalink
Post by Dankert
Hi,
I have a problem hopefully someone could help with.
When I run "NET USE Z: \\Server\Share" from the commandline and then run a
OPEN "Z:\Test.txt" FOR OUTPUT AS #1
PRINT #1,"Hello"
CLOSE #1
everything works as expected, but if I instead run the NET command, using
the same syntax as above, from a SHELL statement like
SHELL "NET USE Z: \\Server\Share"
OPEN "Z:\Test.txt".......
the OPEN statement causes BASIC error 76.
When I use "Windows Explorer" to see if the drive has been mapped it
hasn't.(If SHELLing)
Why cant't I map the network drive from a SHELL statement?
Thanks for your time!
Try using the "persistent" option. type "net use /?" to see the
options. Don't forget to /delete when done.
--
Peter Manders.

Post may contain irony: discontinue use if experiencing mood swings,
nausea or elevated blood pressure.
Dankert
2005-12-02 19:06:06 UTC
Permalink
Thanks for your advice.I finally found what was causing the problem.I have
to provide the SHELL statement with the fully qualified path to the NET.EXE
program as in "C:\i386\NET.EXE".
Post by Peter Manders
Post by Dankert
Hi,
I have a problem hopefully someone could help with.
When I run "NET USE Z: \\Server\Share" from the commandline and then run a
OPEN "Z:\Test.txt" FOR OUTPUT AS #1
PRINT #1,"Hello"
CLOSE #1
everything works as expected, but if I instead run the NET command, using
the same syntax as above, from a SHELL statement like
SHELL "NET USE Z: \\Server\Share"
OPEN "Z:\Test.txt".......
the OPEN statement causes BASIC error 76.
When I use "Windows Explorer" to see if the drive has been mapped it
hasn't.(If SHELLing)
Why cant't I map the network drive from a SHELL statement?
Thanks for your time!
Try using the "persistent" option. type "net use /?" to see the
options. Don't forget to /delete when done.
--
Peter Manders.
Post may contain irony: discontinue use if experiencing mood swings,
nausea or elevated blood pressure.
Loading...