Jump to content

Second Old-School Issue


Recommended Posts

I received some help getting my environment set up in .?do=embed' frameborder='0' data-embedContent> I'm still having issues and not really sure why. I figured I'd post the whole issue and see if someone can tell me what I am doing wrong.

Here is the batch file I am trying to emulate:

@echo off

REM See if T: is mapped to \\server\volume
If exist t:\program.exe goto starthere

REM Unmap T: and re-map to \\server\volume
%SystemRoot%\System32\net use t: /delete  > NUL
%SystemRoot%\System32\net use t: \\server\volume > NUL

:starthere

REM Map a printer to LPT2 (change as needed)  > NUL
net use lpt2 /delete  > NUL
net use lpt2: \\printserver\printer > NUL

t:
program.exe > NUL

As I posted in the the batch file requires that the folowing is set up in C:\WINDOWS\system32\Config.NT:

dos=high, umb
files=125
device=%SystemRoot%\system32\himem.sys
device=%SystemRoot%\system32\emm386.exe NOEMS

(Yes this is a very old program)

I am not worrying about the printer right now, I need to make that more generic, but here's the issue I am having: The "system" needs to be at the correct drive (in this case T:) before running the program. I have tried the working directory options but so far no luck. Here is where I am:

$sShare = "\\server\share"
$sExecutable = "program.exe"

$sVolume = DriveMapAdd ("*", $sShare, 8)
If @error Then
    MsgBox (0, "Error", "Error mapping drive to " & $sShare)
Else
    MsgBox (0, "Success", "Mapped drive " & $sVolume & ": to " & $sShare)
EndIf

EnvSet ("dos", "high, umb")
EnvSet ("files", "125")
EnvSet ("device", "himem.sys")
EnvSet ("device", "emm386.exe NOEMS")
EnvUpdate()

MsgBox (0,"Debug","Executing: " & @ComSpec & " /c " & $sVolume & ":/" & $sExecutable)

RunWait(@ComSpec & " /c " & $sVolume & ":/" & $sExecutable, $sVolume & ":/",@SW_SHOW)

DriveMapDel ($sVolume)
MsgBox (0, "Removal", "Un-mapped drive " & $sVolume & ": from " & $sShare)

Exit

I believe that the executable is not running in it's own directory. When I type the "debug" line into a command prompt I get errors form the program telling me it can't find it's configuration files (not working in the right directory).

This is a long post for what is very likely a simple issue, but I wanted to give enough information so I don't have to keep coming back to the well. Thanks in advance for any assistance.

Link to comment
Share on other sites

  • Moderators

If you're sure that's the issue, then use FileChangeDir() before the Run* call, and back again to @ScriptDir if necessary after.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Well that wasn't it (thank you for replying) but it did send me to find the right answer. The line:

RunWait(@ComSpec & " /c " & $sVolume & ":/" & $sExecutable, $sVolume & ":/",@SW_SHOW)

is what blew me up. Apparently the volume returned by DriveMapAdd has a trailing colon so the correct line was:

RunWait(@ComSpec & " /c " & $sVolume & "/" & $sExecutable, $sVolume & "/",@SW_SHOW)

... and that worked. Damned glasses!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...