Jump to content

variable in a "net use command"


Recommended Posts

There is a way right? The script parses an .ini file for a server name. The server name takes the value of $line.

____________________

$file = FileOpen("c:\server.ini", 0)

$server = FileReadLine($file, 1)

Runwait("net use f: \\$server\vol1\apps")

______________________

Problem is that inside the net use command, I am unable to get the drive to map.

I have tried. wrapping in %, and all other information I was able to read and find, including the help file. I dont think the FAQ item addresses my issue.

Thanks

Dave :iamstupid:

Link to comment
Share on other sites

$server = IniRead ( "myfile.ini", "Headline", "Server", "" )

Run("net use f: "$server & "\vol1\apps /y")

Then you .ini file should look like this:

[Headline]

Server = name of server

Runwait("net use f: \\$server\vol1\apps")

It should look like this:

Runwait("net use f: \\" & $server & "\vol1\apps")

But i always work with iniread when i got .ini files :ph34r:

Edited by Doxie

Were ever i lay my script is my home...

Link to comment
Share on other sites

You can have this as a separate program:

$server = InputBox("Server", "Enter Server name", "")

IniWrite( "myfile.ini", "Headline", "Server", $server )

This little code will just change your server name in the ini file.

AND, you can also use it to create the first .ini file.

Were ever i lay my script is my home...

Link to comment
Share on other sites

My misstake :ph34r:

I'm used to have the \\ in the ini file...

If you gonna use my change server name tool

$server = InputBox("Server", "Enter Server name", "")
IniWrite( "myfile.ini", "Headline", "Server", "\\"&$server )

Otherwise make sure you use \\ in your selfmade .ini

Or

You can enter the \\ in the Net Use command directly

$server = IniRead ( "myfile.ini", "Headline", "Server", "" )
Run("net use f: \\"$server & "\vol1\apps /y")

Hope this help...

Were ever i lay my script is my home...

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...