Create local account in XP
I am looking for a way to check to see if an account exists in XP, and
if not, create it, and keep running the VBS code until it is created and
has Admin privileges(just in case the user add or group add fails). The
only script I have now is the following to create the user. The
questions I have are:
1) Am I creating the user correctly using VBS? (The code does work, but
is there an easier way?)
2) How can I accomplish the goal as stated above using some type of VBS
code?
Thank you,
Matthew
CODE
----
WshShell.Run "NET USER AUTOCAD XXXXXXX /ADD /ACTIVE:YES /COMMENT:AUTOCAD
/EXPIRES:12/31/2004 /FULLNAME:AUTOCAD /PASSWORDCHG:NO"
WshShell.Run "NET LOCALGROUP ADMINISTRATORS AUTOCAD /ADD" Tag: Host to get list of Unconfigured Components Tag: 163987
Checking Domain Membership IsMember not working correctly
I'm using IsMember to check for Domain Admins. I must be doing something
wrong because it comes back positive for all users. Here's the code
strGroup = "Domain Admins"
If IsMember(strGroup) Then
MsgBox "Hello"
End If
Function IsMember(strGroup)
' Function to test for group membership.
' strGroup is the NT name (sAMAccountName) of the group to test.
' objGroupList is a dictionary object, with global scope.
' Returns True if the user is a member of the group.
If IsEmpty(objGroupList) Then
Call LoadGroups
End If
IsMember = objGroupList.Exists(strGroup)
End Function
Sub LoadGroups
' Subroutine to populate dictionary object with group memberships.
' objADObject is the user object, with global scope.
' objGroupList is a dictionary object, with global scope.
Dim objGroup
Set objGroupList = CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare
For Each objGroup In objADObject.Groups
objGroupList(objGroup.name) = True
Next
Set objGroup = Nothing
End Sub Tag: Host to get list of Unconfigured Components Tag: 163986
Accsessing a .pst file via code for publishing to extranet
Hi,
Is there any way I can access the details from a Personal email folder
storage file (.pst) without having to have it in a mail box.
Jeni Tag: Host to get list of Unconfigured Components Tag: 163977
Adding to Path environment variable
I've been looking for a way to add a directory to Path for an installer. I
need to set Path permanently, not just while the command prompt is open, so
I can't use the set command. I figured I should write somewhere in the
registry, so I searched the registry for a directory currently in the Path
system variable, but I couldn't find it. I think I found where PATH data is
stored for the owner, but I'd rather set the Path for all users.
I could call the command line program PathTool (
http://www.digievo.co.uk/software.asp?category=1 ) from my script to add to
Path, but PathTool is a 72K exe with features that I don't need. The
VBScript at http://www.winguides.com/scripting/reference.php?id=138 seems
more practical for my needs, but I need some help to customize it.
I only have access to Windows XP. With a little help from a VBScript
reference (since I don't know VBScript), I was able to customize the
VBScript to add to Path on XP and other NT based systems. I came up with the
following script:
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshEnv = WshShell.Environment("SYSTEM")
WshEnv("Path") = WshEnv("Path") & ";directory/to/add/goes/here"
All I need is a way to sniff out Windows 95, 98 and Me and change the code
as needed when one of those systems is detected. My best guess is to learn
how to read the registry from the command prompt and see if
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\PathName"
contains "C:\WINNT" and if not, assume it's Windows 95, 98, or Me and
(somehow) add to the Path in autoexec.bat, but I don't think users of my
product would appreciate me playing a guessing game with their registry.
Any help would be appreciated.
Barry Tag: Host to get list of Unconfigured Components Tag: 163976
overwrite some files
Hi, I'm Nicola a sysadmin who really needs to start studying some kind
of scripting language........
I need to overwrite some files from a server to a lot of clients in
our network, not to all and the conditions are:
1)to find a folder called "c:\sigla"
2)the files on the server are newer then the clients' one.
All the computers are in a windows 2003 domain (active directory is up
and running) and use a Microsoft OS, from NT workstation to XP. Tag: Host to get list of Unconfigured Components Tag: 163974
Determine user idle time in script
Is there a way to determine (through WMI, or some other way)
time user has been idle (no mouse or keyboard events)?
Drazen! Tag: Host to get list of Unconfigured Components Tag: 163973
ASP, Link Variables and Forms
I am having a brain freeze and need help with an easy question. I have a page
called RemoveClass.asp with a form that has a button to remove a class. There
is one form for each class. They all have the same name. Here is what my code
looks like:
'start looping
<form name="form1"
action="RemoveClass.asp?RemoveClass=<%=ObjRS("ClassID")%>"
method="post"><INPUT type="submit" value="Remove" name=RemoveClass></form>
'move to next class
'next loop
The problem is that when the Remove submit button is clicked the browser
goes to RemoveClass.asp not RemoveClass.asp?RemoveClass=?ID12345. I viewed
the source and there don't seem to be any errors. The class ID is being
inserted properly and when I enter the link manually with the RemoveClass
variable name it works.
How do I put this variable in the link? I know I did this before and I think
it was with the action property. Any ideas? Thanks for the help. Tag: Host to get list of Unconfigured Components Tag: 163962
How can i use "LIKE" ?
I want to compare two string and want to use "LIKE" (user define a string
format), how can I do ? Tag: Host to get list of Unconfigured Components Tag: 163961
Get all users from AD
I have a Vbs script which changes dis[play name to "surname, forename".
What code do I need to connect to AD and apply this to each user?
Any help appreciated
Gordon Tag: Host to get list of Unconfigured Components Tag: 163959
Sending Email From DOS Prompt..
Hi,
I found this on web in this it's using local smtp server.if i want to use
remote
smtp server what changes should i make.
'--------------------------------------------------
'
' Sends email from the local SMTP service using CDONTS objects
'
' Usage:
' sendmail -t <to> -f <from> -s "<subject>" -b "<message>"
' sendmail [-help|-?]
'
'--------------------------------------------------
Option Explicit
On Error Resume Next
Dim objSendMail, oArgs, ArgNum
Dim strTo, strFrom, strSubject, strBody
Set oArgs = WScript.Arguments
ArgNum = 0
While ArgNum < oArgs.Count
Select Case LCase(oArgs(ArgNum))
Case "-to","-t":
ArgNum = ArgNum + 1
strTo = oArgs(ArgNum)
Case "-from","-f":
ArgNum = ArgNum + 1
strFrom = oArgs(ArgNum)
Case "-subject","-s":
ArgNum = ArgNum + 1
strSubject = oArgs(ArgNum)
Case "-body","-b":
ArgNum = ArgNum + 1
strBody = oArgs(ArgNum)
Case "-help","-?":
Call DisplayUsage
Case Else:
Call DisplayUsage
End Select
ArgNum = ArgNum + 1
Wend
If oArgs.Count=0 Or strTo="" Or strFrom="" Or _
strSubject="" Or strBody="" Then
Call DisplayUsage
Else
Set objSendMail = CreateObject("CDONTS.NewMail")
objSendMail.From = strFrom
objSendMail.To = strTo
objSendMail.Subject = strSubject
objSendMail.Body = strBody
objSendMail.Send
Set objSendMail = Nothing
End If
' Display the usage for this script
Sub DisplayUsage
WScript.Echo "Usage:"
WScript.Echo " sendmail -t <to address> -f <from address> -s " & _
Chr(34) & "<subject>" & Chr(34) & " -b " & Chr(34) & _
"<message body>" & Chr(34)
WScript.Echo " sendmail [-help|-?]"
WScript.Echo ""
WSCript.Quit
End Sub Tag: Host to get list of Unconfigured Components Tag: 163955
Need Script Please !! unlock local Adminstrator accounts on 140 machines
We had a virus which I got under control. It tried to hack every
administrator account on the local machines and therefore locked about
every one of them.
I am just learning scripting, and not a pro by any means yet. I have
about 140 machines and the names of the machines. I can put the names
in a txt or csv file. I have tried a few things but just can't get it
working. Any help would be appreciated.
A script template where I could fil in the blanks IE: csv file or text
file or domain info etc would be greatly appreciated.
stoneyw@triad.rr.com Tag: Host to get list of Unconfigured Components Tag: 163954
Taskbar toolbars
Is it possible to add a custom toolbar to the taskbar using VBScript?
This would be the same as right-clicking on the taskbar, choosing
Toolbars, then "New toolbar". Are these toolbars stored in the
registry somewhere? Tag: Host to get list of Unconfigured Components Tag: 163951
VBscript to send mail
Dear all
how do i write a script, to send mail to myself if the
anti-virus is not installed.we use exchange 2000.
Eashwar Tag: Host to get list of Unconfigured Components Tag: 163948
How to start a excelfunction
Hello,
How can I start an Excel Sub or Function?
set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
set WB = xlApp.workbooks.open _
("F:\XY.xls")
name of function = test1
what is the right code?
run WB?
Thank you
Wolfgang Tag: Host to get list of Unconfigured Components Tag: 163946
Running vbscript when PC starts
I want to run a vbscript each time my PC starts and before any user has
login. The vbscript changes user passwords.
Where should I place or install the script?
Thanks Tag: Host to get list of Unconfigured Components Tag: 163934
XCACLS not reading file path with space
When I run the function below, all works well until there is a space in a
folder name. Then XCACLS only reads to the space and then errors out because
of bad path...
Any ideas...
Function Subfolder(Folder)
For Each objFolder in Folder.Subfolders
ReDim Preserve arrSubfolders(intSize)
ReDim Preserve arrPermissions(intSize)
arrSubfolders(intSize) = objFolder.Path
'arrPermissions(intSize) = objFolder.Permissions
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("Wscript.Shell")
objName = arrSubfolders(intSize)
objFileName = objFolder.Name & ".txt"
Set objTextFile = objFSO.CreateTextFile(objFileName)
objTextFile.Close
Set objTextFile = objFSO.OpenTextFile(objFileName, 1)
objShell.Run "cmd /c cscript xcacls.vbs " & objName & "> " & objFileName,
intWindow, True
objTextFile.Close
intWindow = 0
Set objTextFile = objFSO.OpenTextFile(objFileName, 1)
Do While objTextFile.AtEndOfStream <> True
strText = objTextFile.ReadLine
'Put info into spreadsheet here
If Mid(strText, 12, Len(objRecordSet.Fields("Name").Value)) =
objRecordSet.Fields("Name").Value Then
objSheet.Cells(row,6).Value = objFolder
End If
ReDim Preserve arrPermissions(intSize)
arrPermissions(intSize) = arrPermissions(intSize) & vbLfCr & strText
WScript.Echo strText
Loop
objTextFile.Close
intSize = intSize + 1
Subfolder objFolder
Next
End Function
Thanks.... Tag: Host to get list of Unconfigured Components Tag: 163932
Sub fails syntax check, but only within function
I have a blob of code that I run as part of a custom action within a Windows
Installer session. This code runs flawlessly every time it has run. I
decided to get cute and use error-handling, so I wrapped the code in a
function declaration. Now it bombs instantly with a syntax error. I don't
understand why.
code
..
..
code
works fine, but
Function SomeFunction()
code
..
..
code
End Function
dies. Does this make sense? There is a subroutine in the code blob that
calls itself recursively (it's a registry delete code blob). Can you not
run subs within functions?
Any help would be appreciated. Tag: Host to get list of Unconfigured Components Tag: 163926
Help with debugging
Can someone please tell me why the following code does not behave correctly?
When processing the "IF THEN" statement it chooses the correct "exe" from
the INPUTBOX and the MSGBOX I create runs correctly but then the script
continues to process the next statement after the "ELSE" and displays the
second msg box as well, even though it correctly does not run the 2nd
executable. What am I doing wrong? How do I isolate the MSGBOX to only the
first statement?
Option Explicit
On Error Resume Next
Dim objShell
Dim objScriptExec
Dim strmsg1
Dim strmsg2
method = InputBox ("Run test 1 or test 2?", "TEST", "1")
strmsg1 = MsgBox ("You are test1", 64, "1")
strmsg2 = MsgBox ("You are test2", 64, "2")
Set objShell= CreateObject("Wscript.Shell")
If method = "1" Then
Set objScriptExec = objShell.Exec ("1.exe")
strmsg1
Else
If method = "2" Then
Set objScriptExec = objShell.Exec ("2.exe")
strmsg2
End If
Any help would be appreciated, thanks! I'm trying ;)
Derek Tag: Host to get list of Unconfigured Components Tag: 163925
Select Case problem
I am trying to write a script that will perform some commands on all folders
in a directory that start with a list of characters. For now I am just
echoing the folder names. In this case I need all folders that start with a,
b, or c. In the code below I am creating a virable named oCaseString that =
"a","b","c". When the line [Case oCaseString] is read it does not find any
matches even though there are a number of directories that start with a, b,
or c. If I change th line to [Case "a","b","c"] it works. I cannot figure
out why the variable is not working. Any help will be greatly appreciated.
=============================
Set oFile = CreateObject("SCripting.FileSystemObject")
homePaths = Array("serverName|shareName|a.b.c")
For Each Item In homePaths
tmp1 = Split(Item, "|")
tmp2 = Split(tmp1(2), ".")
For i=LBound(tmp2) To UBound(tmp2)
tmp3 = tmp3 & chr(34) & tmp2(i) & Chr(34) & ","
Next
tmp4 = (Len(tmp3) -1)
oCaseString = Left(tmp3, tmp4)
oString = Chr(34) & "a" & Chr(34) & "," & Chr(34) & "b" & Chr(34)
Set oFolder = oFile.GetFolder("\\" & tmp1(0) & "\" & tmp1(1))
Set oSubFolderList = oFolder.SubFolders
For Each Folder In oSubFolderList
Select Case LCase(Left(Folder.Name, 1))
Case oCaseString
' Case "a","b","c"
WScript.Echo folder.name
Case Else
WScript.Echo "x"
End Select
Next
Next Tag: Host to get list of Unconfigured Components Tag: 163920
Identifying and copying new files in a directory
1. I'm a vbscript newbie, so please forgive the clumsiness.
2. Background:
My fax server creates pdf's and text files (containing info about the pdf's)
bearing the same names, except for having different extensions (.pdf or
.txt).
I want to (A) identify new files (i.e., from within the last hour) in the
source directory, and (B) copy those files to a target directory, and (C)
assign new names to the new pdf files, based on info in the text files.
This Posting is to elicit opinions about whether my plan for doing the
above is the right way to go.
I have not yet learned how to use two-dimensional arrays (which I presume
would be a better way to go), so I'm planning to do the following:
1. Use a batch file and a cscript file (both shown at the bottom of this
message) to write the directory to a text file (DirFileList.txt), showing on
each line one filename and the date/time of the file. The date/time will be
at the left margin of DirFileList.txt.
2. Use a loop to go down each line of DirFileList.txt to compare the
date/time to Now.
3. If the comparison returns a number that is smaller than 4 hours, find
the filename string to the right, and use that string to find the filename
"root" for the related files to be copied (i.e., the filename except for the
.txt or .pdf extension), e.g., Alpha.txt and Alpha.pdf.
4. Use the filename "root" to open the Alpha.txt file and harvest the info
to use in generating the filename to assign to the new copies of Alpha.txt
and Alpha.pdf
5. Make the new copies of Alpha.txt and Alpha.pdf
6. Continue the loop until done.
I bet there's an easier way.
Well, here's the batch file I'm using to create the text file :
cscript //nologo "List.FaxDir's.Files.To.A.TextFile.vbs" >
k:\BlahBlah\Fax\NewFaxes.txt
Here's the vbscript file:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("k:\BlahBlah\Fax")
Set colFiles = objFolder.Files
Const ForWriting = 2
For Each objFile in colFiles
strNoww = objFile.DateLastModified
Wscript.Echo "strNoww =" & strNoww
Wscript.Echo objFile.DateLastModified, objFile.Name
'* objFile.Write objFile.DateLastModified, objFile.Name
Next
Any ideas/comments/suggestions would be much appreciated.
Thanks, Marc B. Hankin Tag: Host to get list of Unconfigured Components Tag: 163918
Editing Group Policy Registry Entries with VB Script
I am writing a VBScript that will all us to apply a "new computer"
template to a computer just built, as well as audit these settings on
the computer, as well as other computers on the network later. The
idea is to set registry and group policy settings, for multiple
Windows platforms, (2003/XP/2000/NT, etc).
Anyway, looking the the following article, Microsoft cautions "to
change the group policy registry values, use Group Policy. Do not edit
the registry."
The problem is, we have many machines that must run as stand alone,
and we want to run the script on these machines too to set/audit their
settings. So, my question is, other than the obvious dangers of
directly modifying the registry, is there a specific reason why one
should not modify group policy through direct registry modifications?
Thanks
Group Policy Registry Table
http://www.microsoft.com/windows2000/techinfo/reskit/en-us/default.asp?url=/windows2000/techinfo/reskit/en-us/gp/gpref.asp
Jack Tag: Host to get list of Unconfigured Components Tag: 163917
how to Configure IAS in unattended mode?
Hi,
Help needed in creating
1. Radius client
2. New Remote Access Policy
3. New Connection Policy
Any pointers or solutions to this query would be very helpful.
Thanks in advance,
Karthick Tag: Host to get list of Unconfigured Components Tag: 163914
Declaring variable using WshShell.Exec
Hello,
I am trying to run a command line utility via WshShell.Exec using an input
box as a variable. For some reason I cannot get the command to see the
defined variable. Can someone please tell me what I'm doing wrong? Thanks
Option Explicit
Dim objShell
Dim objScriptExec
Dim IMAGE
Set objShell= CreateObject("Wscript.Shell")
IMAGE = InputBox ("What file would you like to burn?","ISO Location","C:\")
Set objScriptExec = objShell.Exec ("cdburn.exe IMAGE -speed max")
Derek Tag: Host to get list of Unconfigured Components Tag: 163910
My account
How retrieve "Who i am" (account name)?
Few person will be logged to the server locally or by terminal and run my
aplication. My aplication will create file whitch name will be
"accountname".xml. I must know who is running it.
How can i retrieve account name? Tag: Host to get list of Unconfigured Components Tag: 163898
VBScript, accessing modems...
Hi,
Please, if someone knows how to do access installed modems, using VBS.
More precisely, I have laptop with bluetooth connection. To connect to
Internet, I use GPRS
bluetooth mobile phone. This way, in order to establish GPRS connection, I
need to specify proper connection string in my bluetooth dialup modem.
(This way: Phone And Modem Options --> Modems --> double click some modem to
access -->
Properties --> Advanced tab --> Extra initialization commands)
So, since I frequently need to change that field for that specific modem on
my laptop, I would like to access that field by VBScript.
Does somebody have some idea how to change that field using script?
Thank you,
Denis
--
/Denis Tag: Host to get list of Unconfigured Components Tag: 163892
Help my "Create desktop shortcut" actually display..
Hi There, I have been having problems with creating a desktop icon - that
will actually be able to run by every user (regardless of user power) on
there desktops - I have been using a simple script - and it is VERY messy, as
Im extremely new to this stuff.. Please can someone view my script and tell
me excatly what is wrong - and how to fixit..
'--------------------
'Create a ShortCut to IT Helpdesk
'Create a WshShell Object
Set WshShell = Wscript.CreateObject("Wscript.Shell")
sAllUsersProfile = WshShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")
Set oShellLink = WshShell.CreateShortcut _
(sAllUsersProfile & "\Desktop\IT Helpdesk.lnk")
set oShell = CreateObject("WScript.Shell")
sDesktop = oShell.SpecialFolders("AllUsersDesktop")
'Create a WshShortcut Object
strDesktop = WshShell.SpecialFolders("AllUsersDesktop")
Set oShellLink = WshShell.CreateShortcut(sAllusersdesktop & "\IT
Helpdesk.lnk")
'Set the Target Path for the shortcut
oShellLink.TargetPath = "Explorer"
'Set the HotKey to activate this link
oShellLink.HotKey = "ALT+CTRL+M"
'Set the icon ( path to your favorite icon)
oShellLink.IconLocation = "C:\IT.ico"
'Set the additional parameters for the shortcut
oShellLink.Arguments = "T:\InterRoute\Helpdesk Support.oft"
'Save the shortcut
oShellLink.Save
'Clean up the WshShortcut Object
Set oShellLink = Nothing
'-------------------------------------
Please help - as the icon displays in the C:\ of the computer - rather than
the Desktop itself.. Any ideas would be greatfully recieved.
Thank you!
James Tag: Host to get list of Unconfigured Components Tag: 163888
Login Scripts
I am moving towards a total MS environment. Getting riud of my Novell
servers. Currently I have login scripts in Novell that map drives to
different network resources and based on group membership they also get
access to other programs and applications. I'd like to replace the Novell
login scripts wiht vbscript but am unsure about creating scripts based on
OU's and group memebrship. any help is greatly appreciated.
Thanks
dpmjr Tag: Host to get list of Unconfigured Components Tag: 163882
Retrive information from DHCP server.
Hi.
I have looked around for information for how to retrive information from a
DHCP server. Information like Scope configurations, Scope options, current
leached, and so on, but I can't seem to find what I'm looking for. There is
a ton of DHCP related scripts, but only for clients.
Any idea's? Mady it chould be done via WMI, I haven't checked that out.
/Johan Christensson Tag: Host to get list of Unconfigured Components Tag: 163876
GetOpenFile using VBS
In VBA I can use the following code to open a file for input.
Dim strSourceFile As String, lngInputFile as Long
strSourceFile = Application.GetOpenFilename("Text File (*.txt),*.txt")
lngInputFile = FreeFile
Open strSourceFile For Input As lngInputFile
This is handy because the source file will change from day to day, and
it enables the user to choose the file to be edited. Since I do not
require excel spreadsheets for my project I would like to do this with
a VB script. Any suggestions? Tag: Host to get list of Unconfigured Components Tag: 163873
script to do very basic windows 2000 server health check
Anyone have a good, simple script that takes some basic metrics for
server health? I guess stuff like CPU activity, memory use, disk IO,
etc...what else should I be asking? Something I could schedule to run
every x minutes maybe.
Just getting started doing stuff like this, so sorry for being a noob. Tag: Host to get list of Unconfigured Components Tag: 163871
create array from text file
I need help displaying just the text in the section
[ProductCatalogsToInstall] from my file in a single message box. The
number of lines of text under that section will not remain static. I
have a feeling an array will do it but I'm lost on how to code that.
Here is my code that pops up a individual message box until data = "".
Thanks in advance for your help.
***START OF CODE***
Const ForReading = 1
Const TristateFalse = 0
Dim aFile, data, fs, f
aFile = "\\Serv1\windist\I386\svcpack.inf"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(aFile, ForReading, True)
For a = 1 To 7
f.SkipLine
Next
Do
data = f.ReadLine
WScript.Echo data
If data = "" Then
Exit Do
End If
Loop
***END OF CODE***
The file I'm reading from:
***START OF FILE***
[Version]
Signature="$Windows NT$
[SetupData]
CatalogSubDir="\windist\i386\svcpack"
[ProductCatalogsToInstall]
KB837009.cat
KB832894.cat
KB867801.cat
KB823353.cat
KB840315.cat
KB839643.cat
KB839645.cat
KB833987.cat
[SetupHotfixesToRun]
KB837009.exe
KB832894.exe
KB867801.exe
KB823353.exe
KB840315.exe
KB839643.exe
KB839645.exe
KB833987.exe
***END OF FILE*** Tag: Host to get list of Unconfigured Components Tag: 163870
BUG in WScript.Network
Here is a snippet of code that demonstrates a huge bug in WSH
If I use the WScript.Network object o map a drive, and that mapping is
successful. Then I run the script but it dies before saying
RemoveNetworkDrive the drive I mapped is then Ghosted. Running the script
again and having the FileSystemObject say DriveExists() it will say true, if
you try to Unmap RemoveNetworkDrive fails, EnumNetworkDrives doesn't see that
mapping and the asking to MapNetworkDrive says that the local name is in use.
Logging in as the user the scheduled task runs as and asking for output of
'net use' says "There are no entries in the list" but then saying 'net use L:
\\SERVER\Share' says: "The local device name is already in use". Ultra Lame!
Demo Snippit below is my code..copied and pasted minus the meat. But if you
run it you'll see.
' BUG: DriveExists says True event though n.RemoveNetworkDrive says its not
there and the MapNetworkDrive says it's in use, what the FUCK?
' I had to simply ignore errors and hope for the best on this one...suck!
Dim fso: Set fso=WScript.CreateObject("Scripting.FileSystemObject")
Dim n: Set n=WScript.CreateObject("WScript.Network")
WScript.Echo fso.DriveExists("Z")
If (fso.DriveExists("Z")) Then n.RemoveNetworkDrive "Z:"
'On Error Resume Next
n.MapNetworkDrive "Z:", "\\SERVER\Share",False
'On Error GoTo 0
' Do script Here
' Throw an Error before this line, like:
Dim x: x = 1 / 0
n.RemoveNetworkDrive "Z:" Tag: Host to get list of Unconfigured Components Tag: 163868
Netsh
Hello,
I am new to scripting and I am trying to write a script using netsh that
allows you to change from a static to dynamic IP address. I would like to
present the end user with the option of choosing either static or dhcp as
the options. What is the easiest way to do this? Any help would be
appreciated. Thanks!
Derek Tag: Host to get list of Unconfigured Components Tag: 163867
BUG in WScript.Network
Here is a snippet of code that demonstrates a huge bug in WSH
If I use the WScript.Network object o map a drive, and that mapping is
successful. Then I run the script but it dies before saying
RemoveNetworkDrive the drive I mapped is then Ghosted. Running the script
again and having the FileSystemObject say DriveExists() it will say true, if
you try to Unmap RemoveNetworkDrive fails, EnumNetworkDrives doesn't see that
mapping and the asking to MapNetworkDrive says that the local name is in use.
Logging in as the user the scheduled task runs as and asking for output of
'net use' says "There are no entries in the list" but then saying 'net use L:
\\SERVER\Share' says: "The local device name is already in use". Ultra Lame!
Demo Snippit below is my code..copied and pasted minus the meat. But if you
run it you'll see.
' BUG: DriveExists says True event though n.RemoveNetworkDrive says its not
there and the MapNetworkDrive says it's in use, what the FUCK?
' I had to simply ignore errors and hope for the best on this one...suck!
Dim fso: Set fso=WScript.CreateObject("Scripting.FileSystemObject")
Dim n: Set n=WScript.CreateObject("WScript.Network")
WScript.Echo fso.DriveExists("Z")
If (fso.DriveExists("Z")) Then n.RemoveNetworkDrive "Z:"
'On Error Resume Next
n.MapNetworkDrive "Z:", "\\SERVER\Share",False
'On Error GoTo 0
' Do script Here
' Throw an Error before this line, like:
Dim x: x = 1 / 0
n.RemoveNetworkDrive "Z:" Tag: Host to get list of Unconfigured Components Tag: 163866
vbScript and .net
How can you preserve the state of items that were added through vbscript on
the client? Whenever I add items on the client, the server does not recognize
the changes. Tag: Host to get list of Unconfigured Components Tag: 163865
Variables
I'm trying to write a login script that uses the output or variable
from a batch file as the input variable in vbscript.
Alternatively I could use vbscript to pull the variables from a tex
file.
Anyhelp greatly appreciate
-
nogoo
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
----------------------------------------------------------------------- Tag: Host to get list of Unconfigured Components Tag: 163854
Registry permission with script
Dear all,
Anybody has idea with how to change access right for specific registry key?
Please advise.
Thanks,
B.S. Tag: Host to get list of Unconfigured Components Tag: 163849
Function vs Sub
Hi,
Both scripts below work the same way and give the same result. Why should I
use Function, or why should I use Sub, or doesn't it matter at all ?
Regards,
Xander
=====================================================
Option Explicit
Dim oFso, i
Set oFso = CreateObject("Scripting.FileSystemObject")
i = 0
Do Until i = 10
i = i + 1
Call Log(i)
Loop
Wscript.Echo "Done !"
Sub Log(sLog)
Dim sText
Set sText = oFso.OpenTextFile("c:\log.txt", 8, True)
sText.WriteLine(sLog)
sText.Close
End Sub
=====================================================
Option Explicit
Dim oFso, i
Set oFso = CreateObject("Scripting.FileSystemObject")
i = 0
Do Until i = 10
i = i + 1
Call Log(i)
Loop
Wscript.Echo "Done !"
Function Log(sLog)
Dim sText
Set sText = oFso.OpenTextFile("c:\log.txt", 8, True)
sText.WriteLine(sLog)
sText.Close
End Function
===================================================== Tag: Host to get list of Unconfigured Components Tag: 163846
Changing user password
I have 3 user accounts on my PC. I am looking for a vbscript that will
change the account passwords without going to control panel etc etc. My PC
is not on a network. Any help is greatly appreciated. Tag: Host to get list of Unconfigured Components Tag: 163845
VBScript to check PXE enabled or disabled
Hi Admins,
I am looking for a script to verify PXE (Pre-boot eXecution
Environment) is enable or disable.
Please let me know,if you find a script.
Thanks,
Ballu Tag: Host to get list of Unconfigured Components Tag: 163844
Copy log results to DB, then clear log?
In technet, I see there are scripts to do:
1. Backup log, clear log.
2. Copy log results to db
I want to copy the log results to a DB, then clear the log.
Any examples of how to do this?
--
Cheers,
James Goodman Tag: Host to get list of Unconfigured Components Tag: 163840
Writing a scipt to see if a program is active and quit if not
Can anyone tell me how to write a script that could check if a program is
running and quit it if it is?
And for extra credit, is it possible to check, if the program is running,
when's the last time it was used, and only quit it if it hasn't been used
for 15 minutes?
The application is I want to run a schedule job that runs after business
hours and quits Quickbooks if anyone left it open. However, occassionally
people are working from home, and if they are actually working after
business hours, I don't want it to quit on them. I'd then check again an
hour later.
- Sterling Tag: Host to get list of Unconfigured Components Tag: 163837
Folder redirect script on win98
Hi,
I'm trying to redirct "My Document" folder on a win98 client to the user's
home directory on a win2003 sbs server.
Is it possibile with a script or a command?
Pls help!
Thank you
DiAbLo Tag: Host to get list of Unconfigured Components Tag: 163835
Server 2000 scripts
I have created VB logon scripts within my Domain forrest under OU's for
departments, I recently rebooted my 2000 Server and the logon scripts ran
during the server start. All the scripts are set to Block policy inheritence,
how are they leaking out to run on server start (I do not want the scripts to
run on the servers) Tag: Host to get list of Unconfigured Components Tag: 163834
Survey free space on mounted Volume
Bonjour,
Hello,
I'm searching to get available space on a directory mounted volume (mounting
point), using vbs.
I 've found the WMI function "WIN32_Volume", but it works only under 2003
and I wand to do it under 2000.
Any idea??
Thanks,
Laurent Tag: Host to get list of Unconfigured Components Tag: 163831
Deliver an asp page as excel and control the cell formatting
I have an asp page which delivers data as an excel spreadsheet by changing
the content type. It works really well for the most but there are a few bits
of data which are character strings of numbers with leading zeros. Because
the default field format is 'general', the leading zeros are dropped, but I
need them to remain and I need to be able to have them copy and pasted in
bulk into another sheet at some other time (so no just putting a space at the
end). What I really need to do is control the format of the cell an format it
for text only.
Has anyone ever done this? I've been looking round for several days now and
not found anything that helps much.
Thanks in advance,
Pete. Tag: Host to get list of Unconfigured Components Tag: 163828
How to send data
Hi,
I need to send an array of data (up to 20k) of info, read from a text file
on the server, to be available to a page to be processed by Javascript, but
preferably hidden from the user. I have no ideas on how to do this.
Can anyone please help.
Dave Tag: Host to get list of Unconfigured Components Tag: 163826
which debugger to use for vbscript?
I'm trying to write some simple standalone vbscript (not embedded in html),
what is the correct debugger/IDE to use with windowsXP?
I downloaded a Windows Script Debugger from microsoft. It is Version
1.0.7295 and is copyright 1997 (seems a bit old).
Anyway, I used this app to create a file test.vbs and typed in
msgbox "hi"
But every menu items in the debug menu is greyed out. How do I execute or
debug? Tag: Host to get list of Unconfigured Components Tag: 163825
Variable Limit
Hi,
I would like to know, what is the limit of a variable in VBScript. Example:
Story = "String 1" & _
"String 2" & _
"String 3" & VbCrlf &_
"String 4"
Msgbox Story, VbOkOnly
In the variable STORY, I have many lines of text and the text is display
correcly at the screen with the MsgBox command. I add many new lines to the
variable Story and now, when I display the variable with the command MsgBox,
I don't see all new lines.
Why ? What is the limit of a variable ?
Thanks,
Steve Tag: Host to get list of Unconfigured Components Tag: 163820
Adding datetime stamp to file
Hello,
I'm new to vbscript and have a basic question. I want to add a
datetime stamp to a file that I am moving to a bin folder. I've
looked at past entries in this site and haven't found quite what I am
looking for. Basically, how would I attach a date/time stamp to my
file 'Env.xls' using the below code (or something similar):
dim f, fNew, fso
Set fso = CreateObject("Scripting.FileSystemObject")
f = fso.GetFile("C:\MoveTest.txt")
fNew = "C:\temp\Env.xls"
if fso.FileExists(f) then
fso.MoveFile f, fNew
end if
Thanks in advance,
JPA Tag: Host to get list of Unconfigured Components Tag: 163819
Does anyone know of a script that will display a list of unconfigured
components on a 2003 Server?
Thanks