Sign in to follow this  
Followers 0
dcjohnston

variable in a "net use command"

6 posts in this topic

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:

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Excuse the newb,

So no back slashes in the net use command?

Also, thanks for the change of .ini function.

Dave

Edited by dcjohnston

Share this post


Link to post
Share on other sites

Works like a charm. Thanks for the education.

Dave

Share this post


Link to post
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...

Share this post


Link to post
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
Sign in to follow this  
Followers 0