RUNAS inside of .vbs
I need to run this under a user account that has administrative rights
Can I put in a username and password in clear text inside the .vbs script?
set WshShell = CreateObject("WScript.Shell")
On Error Resume Next
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\FLEXlm License
Manager\ADSKFLEX_LICENSE_FILE"
set oEnv=WshShell.Environment("System")
oEnv("ADSKFLEX_LICENSE_FILE") = "@server"
wscript.echo "DONE Importing VARIABLES"
--
Dave Tag: Check Services with no WMI Tag: 196168
ObjUser.putex gives me "unspecified error"
When I run the following command in my script, I get "Unspecified Error"
Const ADS_PROPERTY_APPEND=3
Set objUser = GetObject("LDAP://" & userDN)
'User DN is correct as I can verify it using the message box below.
MsgBox "Writing to " & objUser.DistinguishedName
objUser.putex ADS_PROPERTY_APPEND,"proxyAddresses","/o=Org"
objUser.SetInfo
Thank you! Tag: Check Services with no WMI Tag: 196167
Network Adapter Protocols and Binding Order
I am trying to script the following:
1. Determine the Network Connection Binding order on a machine that has
multiple Network Adapters.
2. Enumerate the list of Protocols associated with a particular network
Adapter. I already have a script that would enumerate all Protocols
installed on a machine.
I would prefer to go the WMI way, if possible. However, I can live with
reading registry values for now.
Any help is appreciated.
Thanks in advance,
ganesh Tag: Check Services with no WMI Tag: 196166
How do I grab IP address from a connection?
I'm not sure where to start - say I have a connectoid "VPNFOOBAR". I
connect to it and then I need to add a route, like "route add 10.0.4.0
mask 255.255.255.0 <assigned address from VPNFOOBAR>". I can script the
connection, but I can't figure out how to grab the assigned IP address.
Can anyone help?
Thanks in advance! Tag: Check Services with no WMI Tag: 196162
RMTShare/Permissions
I'm needing to get a list of shares from specified servers and the
permissions on said shares. Not being too good at VBScript, I ran across
RMTShare. My problem is, by simply running "rmtshare \\server" I get a list
of shares on the server, but not their permissions. For this I'd need to
run "rmtshare \\server\share". The problem is that I need to automate the
process. Does anyone know how I could do this with or without rmtshare? Is
there some way to store the share list in a file (i.e. "rmtshare \\server >
file.txt") and then have a VBScript access the file's data as an array to
fill in "rmtshare \\server\share"? TIA. Tag: Check Services with no WMI Tag: 196158
Is the syntax correct?
Hi,
Need help to check is the syntax correct:
WshShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\ActiveDesktop"
"NoDeletingComponents"=dword:00000001
"NoEditingComponents"=dword:00000001
"NoCloseDragDropBands"=dword:00000001
"NoMovingBands"=dword:00000001
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run "RUNDLL32.EXE Shell32.dll,SHExitWindowsEx 0"
WScript.quit
Is it OK? Tag: Check Services with no WMI Tag: 196155
EXE from ASP w/db connection
I have an exe (VB) that performs updating and table inserts.
Currently, a user would simply double click the exe to execute.
Now I want to call this from ASP. When I do so, my log file (which is
created w/in the exe) says that 'Login failed for user '(null)'. Reason: Not
associated with a trusted SQL Server connection.'
Now my db connection string in the exe is set to use Integrated Security.
Within IIS, I'm using anonymous access with 'WebUser' as my username. I
granted this user full control under security for the exe. Again, if I
simply double click the exe and run it, all is well. But calling it from the
asp page gives me the login failed response. Tag: Check Services with no WMI Tag: 196154
How to enable NTFS inheritance flag?
I need a script that given a folder path,set its NTFS inheritance flag.I need
it to be able to also interprete UNC paths and work in the current user
security context,without requiring WMI permissions on the hosting system(the
problem I actually have when using xcacls.vbs;because the running user needs
to have full permission on both issuing and hosting nodes' WMI
namespace;which I don't want to mess with;specially when the hosting
fileserver is also my domain controller). Tag: Check Services with no WMI Tag: 196149
Runas
I am new to scripting. I am trying to find out how I can preset the username
and password of an admin account so that 2 pieces of software can be
installed on our users devices with the Administrators needing to walk to
every desk. Tag: Check Services with no WMI Tag: 196145
Run script on remote computer
We have 10 Windows 2003 domains (1 root, 8 children, 1 grandchild) and 28
Windows 2003 Domain Controllers.
company.com (2 DCs)
childA.company.com (2 DCs)
grandchildA.childA.company.com (4 DCs)
childB.company.com (4 DCs)
childC.company.com (4 DCs)
childD.company.com (3 DCs)
childE.company.com (3 DCs)
childF.company.com (2 DCs)
childG.company.com (2 DCs)
childH.company.com (2 DCs)
At the end of this message is a script called MasterScript. MasterScript
causes each and every Domain Controller in the forest to locally run its own
local copy of a second script called SlaveScript. I run MasterScript from my
workstation, which is a member of ChildA.company.com, and I run it using
Enterprise Admin credentials from the root domain (company.com). Everything
works just fine except that in exactly 2 of the child domains (child C and
child F) none of the 6 Domain Controllers will locally run their local copy
of SlaveScript. When I locally log into each of the 6 problem Domain
Controllers using the same Enterprise Admin credentials, I can manually run
the local copy of SlaveScript and it works fine.
So it seems that the childC and childF domains (or at least their DCs) are
set to not allow remote script execution. What am I missing?
----------- MasterScript -------------------------
str_exeToRunRemotely = "WScript.exe " & Chr(34) & "C:\Program
Files\EventLogArchive\SlaveScript" & Chr(34)
For int_counterI = 1 To 28
' Connect to WMI
set obj_WMIService = GetObject("winmgmts://" & ary_str_DCs(int_counterI) &
"/root/cimv2")
' Obtain the Win32_Process class of object.
Set obj_process = obj_WMIService.Get("Win32_Process")
Set obj_program = obj_process.Methods_("Create").InParameters.SpawnInstance_
obj_program.CommandLine = str_exeToRunRemotely
' Execute the program now at the command line.
Set obj_shell = obj_WMIService.ExecMethod("Win32_Process", "Create",
obj_program)
Next
----------- MasterScript ------------------------- Tag: Check Services with no WMI Tag: 196143
find dile owned by user
Hello
I have a problem....on a file server I have to find all the file owned
by user and put the list in a file, for example in a excel spreadsheet.
I can use only a vbscript, I can't install software to do this task.
But I'm a beginner on VBscript, so please can some one help me ?
Thanks
Luca Tag: Check Services with no WMI Tag: 196133
Datediff
Hello,
I have a problem implementing datediff function in script with the
input from txt file, where the data is in the followingformat:
10:00
08:01
I need to subtruct the timelast-timeprev, where the timelast is the
first line in the file and
timeprev is the second line in the file. Here is the script:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\timerun.txt", 1)
timeLast = objFile.Read(6)
'wscript.echo timeLast
timePrev = objFile.Read(10)
' wscript.echo timePrev
timeDiff= Round((DateDiff("n", timeprev, timelast)/60),2)
'timeDiff= (DateDiff("n", timeprev, timelast)/60)
timeDiff2= DateDiff("n", timeprev, timelast)
'wscript.echo timeDiff
If timeDiff2 < 60 then
mytime =timediff2
InfoMB=MsgBox ("result:"&Space(1) &mytime &Space(1)
&"minutid",vbInformation + vbOKCancel, "test")
wscript.echo "result:" &Space(1) &mytime &Space(1) &"min"
Do you have any suggestions?
Thanks.
Vitali. Tag: Check Services with no WMI Tag: 196130
Recycling web application
Hi There,
Is it possible to restart and application or recycle the application pool
from within classic asp.
I find the size of the application is becoming too big and cuases a large
number of errors before it recycles itself. I do not want to set timed
recycles but want to be able to do this from within code. Tag: Check Services with no WMI Tag: 196127
executing code on remote PC
Hi,
How can I execute the below code on a remote PC ?
Set objWord = CreateObject("Word.Application")
Set colTasks = objWord.Tasks
For Each objTask in colTasks
If objTask.Visible Then
Wscript.Echo objTask.Name
End If
Next
objWord.Quit Tag: Check Services with no WMI Tag: 196125
Rename Printers in Server 2000
hello,
I have to rename printers .
Its working fine on XP but on Windows 2000 Server i am having the error:
C:\script\printerrename1.vbs(14, 5) Microsoft VBScript runtime error: Object
doesn't support this property or method: 'objPrinter.RenamePrinter'.
I have learnt that RenamePrinter is not compatible with Windows 2000 Server.
Can you please suggest me some other ways of doing it:
Here is the my script that i run
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer")
For Each objPrinter in colPrinters
If Left(objPrinter.DeviceID,22) = "Client\pailles_dom-nns" Then
Wscript.Echo objPrinter.DeviceID
Wscript.Echo Mid(objPrinter.DeviceID, InStrRev(objPrinter.DeviceID, "\") + 1)
varprint= Mid(objPrinter.DeviceID, InStrRev(objPrinter.DeviceID, "\") + 1)
objPrinter.RenamePrinter("hp LaserJet 1320 PCL 5e")
END IF
Next
Thanks
Nazeedah Tag: Check Services with no WMI Tag: 196122
Creating filters over results of an ASP page
Hello everyone. i've been learning a lot here in the past few weeks,
but unfortunately it's not enough for what i need now...
Here it goes:
I have an ASP script wich scans a given directory and returns
information on the files inside it (name, type, size, date last mod,
owner and author). Everything works fine, but now i need a new element
on this - a way to filter the results.
someone i know has told me something about recordsets, but all the info
i can find is about connections with Access databases.
so, i'd like to ask if there is a way to sort my problem out, and if
you know any links or online documentation to do so.
best regards and thanks in advance,
ember Tag: Check Services with no WMI Tag: 196111
Adding a File menu in HTA
I am a beginner with HTA and would like to display a simple
html page and give the user 3 choices.
Save..
Print Preview...
Print...
I know how to create the simple page....
can someone explain how I add a regular 'File' menu with the above options.
Thanks,
Charles W Tag: Check Services with no WMI Tag: 196101
Using User32.dll function from VBScript(WSH)!?
Is there a way, to use a user32.dll function over Scripting Host in
Visual basic Script?
Greeting
A.Gallus Tag: Check Services with no WMI Tag: 196099
Switch proxy (On/Off)
I search for vbscript (or small utility) to switch IE proxy (On/Off) for the current connection (modem).
Saku. Tag: Check Services with no WMI Tag: 196098
Find Replace
On a Windows 98 machine I have space delimited files with a data string for
each hour of the day. I want to use a vbscript to change the value in the
4th
column to 9999 when the time stamp in the 2nd column is 0300 as in the 3rd
row here. I'm not a programmer.
JO 09030100 * 0.0266 * * * 82 * * * * * * 39 33 * * 5915
JO 09030200 * 0.0374 * * * 82 * * * * * * 81 90 * * 5913
JO 09030300 * 0.1378 * * * 82 * * * * * * 78 157 * * 5914
JO 09030400 * 0.0311 * * * 82 * * * * * * 65 210 * * 5915 Tag: Check Services with no WMI Tag: 196096
Raising Message Priority
I am using the CDO.Message object to notify me of copy job results. These run
every hour and are quite cumbersome to go through each day for 8 copy
scenarios.
Is there a property I can change to raise the priority of the email using
vbScript? I have only been able to find examples of doing this thorugh .NET,
which is not applicable for my environment.
Thanks.
Bart Perrier Tag: Check Services with no WMI Tag: 196095
Count items in outlook folders
Hi...
Is there any way to count items in an outlookfolder with a script.
Please show me how.
kindly
Mariah Tag: Check Services with no WMI Tag: 196086
Script to cycle through the open IE windows
Below is a vbs script (and also an au3 script) that I use to activate =
the most recently active IE window. I run the vbs file with a Winkey =
combo. It's a great convenience. I can jump back instantly to the last =
IE window without having to reach for the mouse or use Alt+Tab. =20
What I would like to do is have a vbs script that will activate in =
sequence all of the open IE windows. Let's say I have 10 windows of all =
types open, and five of them are IE windows. Running the vbs file would =
first activate one IE window, running it again would activate the next =
IE window, and so on. This way I could have instant easy access just to =
the IE windows without having to use Alt+Tab or other means that involve =
all of the open windows. =20
Is this possible?=20
Thanks,
Larry
Option Explicit
dim w
With WScript.CreateObject("WScript.Shell")
w =3D .AppActivate("Internet Explorer")
End With
In case this is not possible with WSH, here is an au3 script that also =
activates the most recently activated IE window. Perhaps it could be =
modified to do what I want. =20
AutoItSetOption ("WinTitleMatchMode", 2)
If WinExists("Internet Explorer") Then
WinActivate ("Internet Explorer", "")
EndIf Tag: Check Services with no WMI Tag: 196079
how to wait for a objShell.Exec finish executing a command?
I am creating a shell object to zip a file, then delete the source file, but
the objFSO.DeleteFile(objFileName) is executing before the zip is done, and
deleting the file before it can be zip; so i think. I am checking the error
code for anything other than zero, and it looks like the file is getting
zipped but the delete happens so fast i can't be sure where the problem is.
Obviously if i comment the DeleteFile method i see the file get zip. Do i
need to put some sort of Sleep/Wait variable in my script?
B Tag: Check Services with no WMI Tag: 196076
Scanning VBScript for Unused Variables
Is there an easy/free way to scan a large VBScript for unused variables?
Visual Studio 2005 is supposed to have an autocorrect feature, but I can't
find how to turn it on. Either that, or its always on and it just doesn't
display anything for scripts.
Thanks!
--
Joseph Morales Tag: Check Services with no WMI Tag: 196067
vbscript delete files in a directory older than 30 days with 3 different extensions
I'm sorta new to vbscript but am looking for a vbscript that will:
1.)Delete files in a single directory(and any subfolders below that
which contain) 3 specific extensions and only delete these specific
files that are 30 days or older.
I've seen some that do either do all files in a directory and older
than 30 days but not the criteria below.
I would appreciate any help.
Thanks Tag: Check Services with no WMI Tag: 196066
Split folder with a huge amount of files
I have a folder with a huge amount of files.
So i'd like to split this folder in several new folders with approximately
2000 files each (moving the files).
Can i do this with a vbscript ?
Robertico Tag: Check Services with no WMI Tag: 196064
running multiple instances of CSCRIPT to go through list of computers.
Hello All,
I have been searching far and wide for a solution to my problem. I'm
not sure if I am using the proper terms here. I am fairly familiar with
VBS. Here is the question.
I would like my VBscript to start multiple instances of itself and go
through a list of computers I provide. Basically something similar to
this (http://www.mousetrax.com/Downloads.html "Domain Report Manager
") , but much simpler.
I have spent the past couple of weeks breaking down his code and
connecting bits and pieces, but I am pretty overwhelmed. I read through
the documentation he put together, but it only elaborated on tracking
the number of instances... not how to create them. I am sure it is
something simple, I just can't see it.
The script I have pieced together gathers the computer accounts from
the domain... Pings them.. Then runs PSEXEC against the ones that are
up. I just want to speed up the process. run like 15 threads at once..
I really appreciate any info you can give me or any resources you can
point me too. I really want to learn how this works.
Many Thanks,
Ian Tag: Check Services with no WMI Tag: 196060
trouble in connecting with wmi accross NAT
Dear all,
this is my scenario
I need to manage some servers in the remote offices. I have a cisco
pix-firewall
and also the remote networks have it.
A remote server ( I will call it MYSERVER ) is reachabled with the
Public address 81.81.81.43 (eg.) , on the inside lan MYSERVER adress is
192.x.x.x. ( ie a private address) so a Static NAT translates the ip to
private and viceversa.
my computer is in the inside lan with a private address and goes out with a
public address like 82.83.84.56 (eg).
the server is in the same domain as the mine.
I'm an Enterprise Admin.
If i try to connect to this server with a wmi script, for example using the
ScriptomaticV2 tool, I can't get the data.
But if I add to MYSERVER the ip alias 81.81.81.43 ( the same address
with it is pubblished) i can get all data, but that's a terrible
workaround!!!
Wich is the best solution to avoid this kind of problem?
Many thanks,
Sergio Tag: Check Services with no WMI Tag: 196055
Binary Write method not working
I have moved over some data from 2000 to SQL 2005. The data is the
same, but now some existing working code is not working with the
BinaryWrite method of Response.BinaryWrite.
In a field in a table that is ntext. It contains HTML data tags. ie.
<P><B>this is</B> etc... etc.. </P>
Before moving to 2005 the following code worked (recordset setup
correctly):
dim mFieldSize, mBytes
mFieldSize = rs.Fields("keywords").ActualSize
mBytes = rs.Fields("keywords").GetChunk(mFieldSize)
Response.BinaryWrite mBytes
now with the data in 2005 I get this error:
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another. Is this a coding error, or a type error
problem that I have to do differently with 2005?
If anyone knows of the solution to this problem please let me know.
Thanks
*** Sent via Developersdex http://www.developersdex.com *** Tag: Check Services with no WMI Tag: 196054
bypassing 'File Open' dialog when calling an external program
Group,
I'm running the following command multiple times from a script while
using Terminal Services on a series of Windows 2003 servers:
objShell.Run "Robocopy \\Server1\3rdPartyApps E:\3rdParty *.* /e", 2, True
The VB Script and Robocopy.exe files are located on a remote server.
In 90% of the servers I'm prompted by a 'File Download' window asking if I
want to 'Open' the Robocopy.exe file located on the remote server. If I
select 'Open' the script runs without issue and the necessary files are
copied. My question concerns a way to bypass or avoid being prompted each
time I need to run this command. I assume this is a GPO or security setting?
If so, is there a way to temporarily change this setting at the start of the
script and change it back at the end?
Any help would be appreciated. Tag: Check Services with no WMI Tag: 196053
Object variable or With block variable not set
Hi
I have a problem with following code:
Set pProject = CreateObject ("SAAuto8SP1.ISWiProject")
' Dim pProject
' Set pProject = New SAAuto8SP1.ISWiProject
When i run it i get : "Object variable or With block variable not set"
I have found it is a bug on http://support.microsoft.com/?kbid=316478
but when i change this script and uncomment lines under it I get:
Microsoft VBScript compilation error: Microsoft VBScript runtime
error: Class not defined : 'SAAuto8SP1'
Thanks for your help Tag: Check Services with no WMI Tag: 196050
Forum
Hi,
I want to create a forum with VB Script but i don't know how to save
data to the Hosting server, can you help me ?????
OMAR ABID Tag: Check Services with no WMI Tag: 196046
Single Application shell for windows
Hi all,
My vbscript is the following:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2:Win32_Process")
errResult = objWMIService.Create("C:\Program Files\Adobe\Acrobat
7.0\Reader\AcroRd32.exe", "C:\Program Files\Adobe\Acrobat 7.0\Reader\",
null)
set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colProcesses = objWMIService.ExecNotificationQuery _
("Select * FROM _InstancedeletionEvent " _
& "Within 1 Where TargetInstance ISA 'Win32_Process'")
Do Until False = True
Set objProcess = colProcesses.NextEvent
If objProcess.TargetInstance.ProcessID = intPosID Then
Exit Do
End If
Loop
All I want to do is display Acorbat Reader as the shell instead of
Explorer.exe which works fine. My problem is that I want the user to
log off when he terminates Acrobat Reader. This script produces an
error on line: 5 char: 1 Error: Not found.
As is Acrobat Reader starts as the shell but the rest of the script
doesn't work. Can anyone help me with this pls? Tag: Check Services with no WMI Tag: 196045
iNCLUDE LEADING ZEROS
Hi all,
How do I include the leading zeros in the date?
YEAR(NOW) & MONTH(NOW) & DAY(NOW) & ".xls"
Thanks
gv Tag: Check Services with no WMI Tag: 196034
WMI to get the size of physical drive 0
I'm booting off of a WINPE CD and I need to find out the size of drive 0
before I format and restore my image to it.
Anyone have anything that can accomplish this?
Thanks Tag: Check Services with no WMI Tag: 196027
Status on a servic
I wrote a script to try to find the status of a particular service
(ccmexec(sms service)), but it is not bringing anything back even though I
ran it on a box that SMS is installed on. Need Help, here is my current
script.
On Error Resume Next
arrComputers = Array("test")
For Each strComputer In arrComputers
WScript.Echo "Computer: " & strComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service where
name =" & "ccmexec")
For Each objItem In colItems
WScript.Echo "Caption: " & objItem.Caption
WScript.Echo "Name: " & objItem.Name
WScript.Echo "StartMode: " & objItem.StartMode
WScript.Echo "State: " & objItem.State
WScript.Echo
Next
Next Tag: Check Services with no WMI Tag: 196025
Install graphics driver remotely?
Is there a way to perform an INF-based graphics driver installation on remote
systems (i.e. using VBScript & WMI)?
Thanks,
--
Bill Baker Tag: Check Services with no WMI Tag: 196023
DSQUERY command in VBS
Hello All,
I am trying to run DSquery from a vbs for stale machine accounts, have the
results saved to a file, then read the file back in and modify the accounts
listed. I'm not sure if this is possible. Anyone have thoughts on if this is
possible, or another approach?
will this work?
Set DSQuery = oShell.Exec("c:\windows\system32\dsquery.exe computer" &
chr(34) & "ou=test,dc=mydomain,dc=com" & chr(34) & " -stalepwd 60 -limit
10000 >c:\machines.txt") Tag: Check Services with no WMI Tag: 196019
File Editting
I am just learning to use vbscript and need some help. I have a file that
is 12,000 lines in length with approximately 256 characters per line. I was
going to import the file to my data table but contained in the file are some
comma's scattered throughout the records. These pesky little critters are
keeping me from using the DELIMITED function of my IMPORT routine. Can
someone point me in the direction for writing a vbscript routine for
searching each line and replacing each comma with a blank space.
Thanks,
Ted Tag: Check Services with no WMI Tag: 196011
script for temp internet files
hi-
i don't know anything about scripts - esp in VB. i'm not sure if i
even need to do this in VB, but could someone help me?
we have users who open TIFF files constantly. our problem is that this
folder gets full of these files and after a while, users cannot open
any TIFF files. our usual solution is to do the following manually:
Microsoft Outlook uses a temporary folder to save and open the
attachments. By default that folder is: C:\Documents and
Settings\%USER_NAME%\Local Settings\Temporary Internet Files\OLK#\
(where # is a random number).
Some of the latest security updates for Windows 2000 and XP are
preventing folders to be created in that folder. The solution is to use
the regular TEMP folder.
1. Using REGEDIT.EXE locate the following key:
My
Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security
Note: Depending on your version you may have to modify that path after
the "Office" key. You may have folders 8.0, 9.0, 10.0, 11.0, go the
highest number. This is probably the version that you use.
2. Modify the Key "OutlookSecureTempFolder", by replacing "Temporary
Internet Files" with "Temp". For example:
OLD VALUE: C:\Documents and Settings\USER\Local Settings\Temporary
Internet Files\OLK177\ (you may have different number than 177)
NEW VALUE: C:\Documents and Settings\USER\Local Settings\Temp\OLK177\
3. Restart Microsoft Outlook.
in essence, what i need to do is create a script to do this, so that we
can run it before the folders get full, and we don't have to do it
manually every time it happens.
thanks in advance! Tag: Check Services with no WMI Tag: 196009
How to use Active directory in vbscript (asp-page)
Hello!
Is there any examples or anyting. I have ad on other machine and IIS6 on
other. Can I query username / passwords from AD to my vbscript application
somehow?
I need to make simple logon page wich uses active direcory information to
logon people. The problem is that AD is on another network and we have to
make somesort of hole to our firewall to allow iis to use AD.
I know I allso could use IIS basic funtion and integrated windows logon
things. Problem seems to be that there is two different domains and they are
on different networks. Or is it broplem?
t Tag: Check Services with no WMI Tag: 196007
Rename Printer-Urgent PLease!!
hello,
I have to rename printers .
Its working fine on XP but on Windows 2000 Server i am having the error:
C:\script\printerrename1.vbs(14, 5) Microsoft VBScript runtime error: Object
doesn't support this property or method: 'objPrinter.RenamePrinter'.
I have learnt that RenamePrinter is not compatible with Windows 2000 Server.
Can you please suggest me some other ways of doing it:
Here is the my script that i run
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer")
For Each objPrinter in colPrinters
If Left(objPrinter.DeviceID,22) = "Client\pailles_dom-nns" Then
Wscript.Echo objPrinter.DeviceID
Wscript.Echo Mid(objPrinter.DeviceID, InStrRev(objPrinter.DeviceID, "\") + 1)
varprint= Mid(objPrinter.DeviceID, InStrRev(objPrinter.DeviceID, "\") + 1)
objPrinter.RenamePrinter("hp LaserJet 1320 PCL 5e")
END IF
Next
Thanks
Nazeedah Tag: Check Services with no WMI Tag: 196006
Prevent Users Executing a Script Twice
Hi Everyone,
Does anyone know a neat way to prevent users executing a script two or
more time simultaneously? Apart from teaching them to be more patient!
Ideally I'm looking for a way to make the script realise that it is
already running in a previous instance and either just quit or send the
user a message and then quit.
Cheers,
Danny.... Tag: Check Services with no WMI Tag: 195993
RegExp and Replacing Submatches
I have a value, retrieved from a recordset, that contains any number of
hyperlinks to a number. For example:
<a href="123456">Hi</a> <a href='334455'>Hola</a>
What I need to do is parse the string, identify any such valid
hyperlinks, look up each of those numbers in a database, and return a
string that looks something like this:
<a href="/somepage.asp">Hi</a> <a href='/anotherpage.asp'>Hola</a>
Here's the VBScript/ASP code I have written so far:
========================================================
Sub ReplaceSubmatches(sInputHTML)
Dim sReturnValueHTML, iCount, oRegExp, oMatches, oMatch
Dim sHrefValue, sHrefNewValue
sReturnValueHTML = sInputHTML
iCount = 0
Set oRegExp = New RegExp
oRegExp.Pattern = "href[\s]?=[\s\""\']+(.*?)[\""\']+"
oRegExp.Global = True
Set oMatches = oRegExp.Execute(sInputHTML)
If (oMatches.Count > 0) Then
For Each oMatch In oMatches
If (oMatch.Submatches.Count = 1) Then
iCount = iCount + 1
sHrefValue = Trim(oMatch.Submatches(0) & "")
sHrefNewValue = "somevalue" & iCount
If (sHrefValue <> "") AND (StrComp(sHrefValue, sHrefNewValue, 1)
<> 0) Then
Response.Write("Replace " & sHrefValue & " with " &
sHrefNewValue & "<br>")
'// Do something to [sReturnValueHTML]
End If
End If
Next
End If
Set oMatches = Nothing
Set oRegExp = Nothing
Response.Write("<br>" & vbNewLine)
Response.Write("Original Value = <u>" & Server.HTMLEncode(sInputHTML)
& "</u><br>" & vbNewLine)
Response.Write("New Value = <u>" & Server.HTMLEncode(sReturnValueHTML)
& "</u><br>" & vbNewLine)
If (StrComp(sInputHTML, sReturnValueHTML, 0) = 0) Then
Response.Write("Values are identical.<br>" & vbNewLine)
End Sub
========================================================
The main reason I use a regular expression, instead of a straight
Replace() statement, is that the href tags may use double-quotes
(href="..") or single-quotes (href='..') to define a value. What do I
need to do to the above code to replace each href value?
-= Tek Boy =- Tag: Check Services with no WMI Tag: 195991
Copy file to folder - Script failing
I am trying to check for the existence of a folder. If that folder does not
exist create it then copy a file to it. If the folder already exists just
copy the file. I would like to add some type of error checking in the
future. I have listed my script below:
strComputer = "."
Dim objShell
Set objShell = CreateObject("wscript.Shell")
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
UserFolder =
objshell.ExpandEnvironmentStrings("%userprofile%")&"\Application
Data\Sun\Java\Deployment"
Wscript.echo UserFolder
Dim fso
set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(UserFolder) Then
fso.CreateFolder UserFolder
fso.CopyFile "\\citrix01\support\hotifx\deployment.properties.*",
UserFolder
else
fso.CopyFile "\\citrix01\support\hotifx\deployment.properties",
"C:\Documents and Settings\%username%\Application
Data\Sun\Java\Deployment\deployment.properties"
set fso = nothing
end IF Tag: Check Services with no WMI Tag: 195989
vbs script on Windows Xp to find largest files
what would be the format or commands to setup a vbscript to run on XP
to locate large files ( over 500mb) and generate a list. ( searching
for large space hogs) Tag: Check Services with no WMI Tag: 195987
Is it possible to Call a Shell Application from within an HTA
I am working on an HTA that will unlock our local users. Within the code I
use Call Shell. Whenever i test the the HTA I get the following error:
RuntimeError has Occured
Line: 54
Error: Type Missmatch: 'Shell"
Is it possible to call Shell from within the script? Here is a sample of
what my script looks like:
sub unlock(strIp, strUser)
IPAddress = strIp
person = strUser
FirstOctets = Left(IPAddress, 6)
If FirstOctets = "192.15" Then
Msgbox "Calling Whitfield Unlock Program"
stAppName = "C:\Scripts\p.bat " & ipname & " " & person
Call Shell(stAppName, 1)
I've tested the HTA without using the Call Shell and just the message box
and it works. Anyone with any Ideas? Tag: Check Services with no WMI Tag: 195986
Problem:logon script does not run
I've set a logon script path for my user as \\testserver\netlogon\1.vbs .
the problem is that it does not run.my username is 1 and pass is 1.
the script is OK.when the user logs on,if he/she browse to netlogon and
double click 1.cmd,everything goes fine;but I do wonder whats wrong with
server that makes logon script not running.
I tested it on 4 different domains,win2k and 2k3 and non worked.
what mistake I'm probably doing? why the logon script is not triggered?
I also turned debugging on like the following article:
support.microsoft.com/default.aspx?scid=kb;EN-US;221833
but nothing meaningful I got from its log pertaining to this issue.
what is my mistake? Tag: Check Services with no WMI Tag: 195984
problem with "shell and wait"
I've been using VB6 for a few years now, but this is my first foray into VBScript. Here's the problem I'm having:
I need to write a script that installs an application in unattended mode (if it does not already exist),
waits for the install to finish, then installs an update to the application.
For some reason, the 'true' parameter on the wshshell.run command doesn't work.
On a machine which does NOT have the application installed, the install starts - it should run about 5-10 minutes.
Almost immediately, the update starts.
I need it to wait until the application install finishes.
Here's the code -- the msgbox lines are there for testing/development purposes only; they will be removed when I get this debugged.
All help/advice/suggestions will be gratefully accepted.
Thanks --
Carl
' SCRIPT STARTS HERE
msgbox "Starting XYZ install process"
dim ws
Set ws = wscript.CreateObject("Scripting.FileSystemObject")
dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
' is XYZ installed? If not, install it in unattended mode.
if not ws.fileexists("C:\Program files\xyzView\xyzView.exe") then
' the last flag is for "shell and wait"; true halts execution, false continues
Return = WshShell.Run("\\BOZO\common\XYZ\setup.exe /s", 1, true)
end if
msgbox "XYZ install complete"
' apply the XYZ update to this machine
Return = WshShell.Run("\\BOZO\common\XYZ\mv31update.exe /s", 1, true)
msgbox "XYZ update complete" Tag: Check Services with no WMI Tag: 195973
Is there a way to check the Startup mode and status of a service without
WMI?
Create a script to read the value from the registry.
Carlos Felipe Fran=E7a da Fonseca wrote:
> Is there a way to check the Startup mode and status of a service without
> WMI?
>=20
> Thanks!!!
>=20
> Carlos Felipe Fran=E7a da Fonseca