Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone help me with the following? 5

Status
Not open for further replies.

Chambers

IS-IT--Management
Jan 19, 2001
257
0
0
US
Hi guys, I need help with a script to do the following;


If "IP=Whatever I Pick"
Then
con2prt /cd \\servername\printer
Else
con2prt /cd \\servername\otherprinter
End

con2prt.exe resides in the system32 directory and is made by MS. Basically the script would do the following. If the IP is this, then map this printer and make it default..else, map this other printer and make it default.

I only know basic logic, but that is what I would like a batch file to do. Can someone help me out? Thanks!
 
Perhaps something like this ?
Set Sh = WScript.CreateObject("WScript.Shell")
If Sh.Environment("PROCESS")("ComputerName") = "PC133" Then
Sh.Run "con2prt /cd \\shore1\LO"
Else
Sh.Run "con2prt /cd \\shore1\HuntingtonWoods"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try something on these lines.. I'm not sure if you already got your answer or not....

Dim IPAddress, IPAddr, OCTIPAddress

'I use this to check the 3 octet in an IP if it is equal too or between these 2 numbers I set my proxy scripts for that subnet...SO a complete IP would be 'IPADDRESS = OctIPAddress(0) & "." & OctIPAddress(1) & "." & OctIPAddress(2) & "." & OctIPAddress(3)

GetIPAddress()
octIPAddress = split(line,".",4)

If octIPaddress(2)=> 12 and octIPAddress(2) =< 15 Then
'Your Printer Commands
else
'Your Printer Commands
end if


Sub GetIPAddress()

'Get the IP details

set myObj = GetObject("winmgmts:{impersonationLevel=impersonate}!//localhost").ExecQuery _
("select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

'Massage the IP Array

Count = 0
for each IPAddress in myObj
Count = Count + 1
next
ReDim IPAddr(Count - 1)

Count = 0
'Format Results

for each IPAddress in myObj
IPAddr(Count) = IPAddress.IPAddress(0)
line = line & IPAddr(Count)
next

'Display IP Address in Message Box
'To Use the IP Address in a script, reference the variable IPAddr(Count)


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top